...
Code Block |
---|
import imas import getpass import numpy as np from imas import imasdef #creating the Data Entry object which handles the pulse file with shot=15000, run=1, belonging to database 'data_access_tutorial' of the current user, using the MDS+ backend data_entry = imas.DBEntry(imasdef.MDSPLUS_BACKEND, 'data_access_tutorial', 15000, 1) #opening the pulse file handled by the Data Entry object previously created data_entry.open() #creating the 'camera_visible' IDS and initializing it camera_visible_ids = imas.camera_visible() camera_visible_ids.ids_properties.homogeneous_time = 1 camera_visible_ids.channel.resize(1) #using only 1 channel (channel 0) for this example camera_visible_ids.channel[0].detector.resize(1) #using only 1 detector for channel 0 camera_visible_ids.channel[0].detector[0].frame.resize(1) #the array of structure 'frame' contains only 1 element, it is the slice to be appended to the IDS X = 3 #number of horizontal pixels in the frameof 2D 'image_raw' field Y = 5 #number of vertical pixels of in the frame2D 'image_raw' field camera_visible_ids.channel[0].detector[0].frame[0].image_raw.resize(X,Y) #setting the size of the image of the frame camera_visible_ids.time.resize(1) #the time vector contains only 1 element, it is's the time of the slice nb_slices=3 #number of time slices to be added for i in range(nb_slices): camera_visible_ids.time[0] = float(i) #time of the slice for j in range(X): for k in range(Y): camera_visible_ids.channel[0].detector[0].frame[0].image_raw[j,k] = float(j + k + i) #image_raw is a 2D array containing the data (pixels) of the frame if i==0: data_entry.put(camera_visible_ids) #the first frameslice has to be added using put() in order to store static data as well else: data_entry.put_slice(camera_visible_ids) #appending the thecurrent slice to the IDS 'frame' array of structures #closing the Data Entry data_entry.close() |
...