Cases: ENS_CASE
ENS_CASE Methods:
- foo.remote_io("filename",operation[,append=1][,position=pos][,length=len][,data=d]): This function performs IO operations on a file located on the (potentially remote) server. All operations are performed by the server or the SOS (if using the SOS). Note: all IO is considered "binary" format. This method will throw an exception on error.
The valid operations are:
0=read 'len' bytes from "filename" starting at offset 'pos' in the file. The return value is a list with two items:
[the actual data read (as a string) , the final file offset after the read].
1=write the data in 'd' to "filename" at the offset 'pos' in the file.
append may be set to avoid rewriting the file.
append=1 sets pos to the end of the file, while
append=2 uses the position specified by 'pos' .
The return value is the final file offset after the write.
2=query the length of the "filename" in bytes.
- foo.queryfilemap(): reads the extension map and returns a list of dictionaries with the following keys:
'name': the name of the format
'ext1': a list of the allowed extensions for the first filename
'ext2': a list of the allowed extensions for the second filename
'elemrep': the default element representation
- foo.queryactualformat("path","format",autodist): returns a dictionary formed by passing the pathname, format and autodistribute flag through the file extension map. The dictionary returns the name of the reader, the potentially revised autodistribute flag and the pathname that should be used to read the dataset.
- foo.remote_launch(cmd[,target=t][,wait=w]): runs the command ‘cmd’ from this server. It will throw an exception on failure. The other keywords are not finalized.
- foo.queryfileformat(”path”[,case=casenum]): runs the filename through the reader extension map. The returned value (if not an exception) is a dictionary with the following keys:
‘directory’: directory name of the path
‘filename’: the basename of the path
‘reader’: the name of the reader selected
‘secondname’: an optional key if a second (results) name was generated
‘playbefore’: the name of a command file to be played before the dataset is loaded
‘playafter’: the name of a command file to be played after a dataset is loaded
‘element_rep’: the desired element representation (integer)
- foo.directorylisting(”dirname”[,case=casenum][,flags=flag]): lists the files in the noted directory on the remote server. The optional flags parameter allows for the returned list to be filtered to only files that have the following flags (or them together to use multiple flags): enums.DIRENTRY_DIR, enums.DIRENTRY_READABLE, enums.DIRENTRY_WRITABLE, enums.DIRENTRY_SYMLINK. Note: the dirname must end in a ‘/’ or ‘\’ to select a directory. See simple example attached below: server_dir_listing.py .
- foo.queryreaders([case=casenum]): returns a list of dictionaries for the readers for the server, along with all user defined GUIoptions. Each dictionary may contain the following keys:
‘name’: name of the reader
‘desc’: the reader supplied description of itself
‘active’: a boolean, true if this reader has been enabled by preferences
‘filebuttonlabels’: a list of labels for the 4 file buttons: File, Result, Bound, Measured. If an entry is None, the button should not be enabled
‘ID’: the internal reader ID number
‘builtin’: A boolean, returning False if this is a user-defined reader
‘autodistrib’: an integer describing the default SOS auto-distribute setting
‘GUI‘: This optional key contains a list of the user defined toggles, pulldowns and fields. This is presented as three lists (one each for toggles, pulldowns and fields, in that order). The toggle list contains three items: the string label, the default toggle status and the current user selection value. The pulldown list contains four items: the string label, a list of strings for the menu, the default menu selection and the current selection value. The field list contains two items: a label for the field and the current string in the field.
- foo.queryparts([case=casenum][,form=0-3]): returns a list of dictionaries, one per part defined in the input file. This is essentially the part loader information. form=0 returns a list of dictionaries with the info for each LPART. form=3 returns a list of the LPART objects. form=1 returns a tree of dictionaries for the info in each object. form=2 returns a tree of object IDs.
- foo.creategroup(name): creates a new ENS_GROUP object with the passed name. The object will be a child of the ENS_CASE object.
- foo.addchild(obj): makes the passed object a child of this case (if the operation is legal).
- foo.setchildattr(attr,value): recursively execute setattr on all the ENS_PART objects in this case
- foo.setchildattrs(dict): recursively execute setattrs on all the ENS_PART objects in this case
- foo.addchild(v|list[record=1][include_lpart=1]): adds the passed object as a child of this object, removing it from its previous parent, if any. See ENS_GROUP for more details.
- foo.update_lookup_table( (int) which, X_list, Y_list [min=(float) min_val] [,max=(float) max_val] [undefined= (float) undef_val] [flags=(int) flags] [,name=name_str] [,case=(int) caseno]) - used to create a lookup table with 'id' of which, that is used in the LOOKUP function. For example, let's create a variable that remaps the temperature variable in the cube dataset (which has a range from 0 to 48). create a lookup table with ID 1, that maps a variable over the range of 0 to 50, and we'll remap it to something simple (0 100 and then to 200) over the range 0 to 50.
core.CASES[0].update_lookup_table(1,[0,10,20,30,40,50],[0,100,100,100,100,200],0,50)
Now create a new variable using LOOKUP(1,temperature) and it will map the data using this piecewise linear function (and even linear interpolate between the values).
Note: the ENS_CASE object supports Python iteration (see ENS_GROUP for examples).
ENS_CASE Attributes:
- CHILDREN: currently loaded objects (parts, lparts, groups).
- DESCRIPTION: the case name
- SERVERDIR: the server directory from which case data was loaded
- MACHINEARCH: server machine arch
- DEFAULTREADERID: the default reader id for this server
- SERVERBYTESWAP: is the server byteswapped wrt the client
- ACTIVE: is the case currently active
- CASENUMBER: the case’s number
- REMOTEHOST: if a server is attached, the hostname it is running on
- JOBINFO: this is subject to change...
- SERVERINFO: a dictionary of the various path/filenames passed to the server to read data. An example might be: {’resource’: , ‘result’: , ‘file’: ‘ami.case’, ‘boundary’: , ‘measured’: , ‘dir’: ‘C:/Program Files/CEI/ensight90/data/ami’}
- METADATA: metadata
- SERVERXML: the XML formatted text the reader sent back to the client.