cso_file module¶
Create and access file with satellite data extract.
Class hierchy¶
The classes are defined according to the following hierchy:
Classes¶
- class cso_file.CSO_File(filename=None)¶
Bases:
objectStorage for satelite data extract.
If optional
filenameis provided, theRead()method is called to read data from a file. If the optionalvarnamelist is specified too, only selected variables will be read.To create a new track, initialize without arguments and add new variables using the
AddVariable()method. Only certain dimension names and combinations are supported.A dimension size could be obtained with the
GetDimension()method.Pixel arrays could be appended using the
AppendPixels()method, which will create a new variable if not present yet. In this way, pixels from multiple tracks could be collected into a single file, for example all pixels available for a day.The
GetPixelFootprint()could be used to obtain a polygon of a pixel footprint.The original 2D track is sometimes useful for plotting the original layer. Use the
AppendTrack()method to add varaiables for the pixel corners within the track.- Close()¶
Close dataset.
- AddCoord(cname, da)¶
Add coordinate variable.
Arguments:
cname: coordinate name to be createdda:xarray.DataArrayobject
- AddVariable(vname, da)¶
Add variable field.
Arguments:
vname: variable name to be createdda:xarray.DataArrayobject
- Write(filename, unlimited_dims=None, attrs=None, history=[])¶
Write data to provided
filename.Optional arguments:
attrs: dictionairy with global attributeshistory: list of str values that describe how the content was created, this will be added to the globalhistoryattribute
- GetDims(varname)¶
Return variable dimension names.
- GetTrack(da)¶
Extract variable on track grid.
Arguments:
da:xarray.DataArrayor variable name
Return values:
xx: corner longitudes (nimage+1,npixel+1)yy: corner latitudes (nimage+1,npixel+1)values: masked array with values at pixel locations (nimage,npixel)units: str units
The corner locations are created using the following variables that are expected to be present:
track_longitude_bounds: 3D array of longitudes with dimensions('scan','pixel','corner')track_latitude_bounds: idem for latitudespixel: compress index that defines the('scan','pixel')location
Example usage to obtain retrieval from data file that includes the track information:
xx,yy,vcd_retr,vcd_units = dfile.GetTrack( 'vcd' )
Example usage for simulated retrieval from state file:
xx,yy,vcd_retr,vcd_units = dfile.GetTrack( sfile.ds['vcd'] )
- GetTimeRange()¶
Return time range of pixels in file. A variable
timeshould be present for this.
- GetTimeAverage(freq=None)¶
Return average of first and last time value.
Optional arguments:
freq: round time to given fequency, for example ‘60min’.
- GetAttr(name, quiet=False)¶
Return global attribute with provided name. If the attribtue is not present an error is raised, unless
quiet=True.
- class cso_file.CSO_Listing(filename, renew=False, indent='')¶
Bases:
objectStorage for table with file properties. The records describe properties of
CSO_Filefiles, for example the time range of the pixels included. This could be used to quickly scan an archive for filenames with pixels within a requested interval.The content of the table file looks like:
Arguments:
filename: listing file, content is read if this file is already present unlessrenew==Truerenew: (optinal) ifTrue, an existing file is ignored
- Close(indent='')¶
Write table to file.
- Cleanup(indent='')¶
Remove records from table if filename is not present anymore.
- Check(filename, indent='')¶
Return exception if no record for
filenameis present.
- Update(filename, csf, tr=None, xcolumns=[], indent='')¶
Add record (or replace) for
filenamewith information from thecsfCSO_Fileobject.The time range of pixels is read from the
csfobject, unless thedatetime.datetimetuppletr=(t1,t2)is supplied.The optional
xcolumnsspecify a list of global attributes to be added as extra columns.
- Select(tr=None)¶
Return dataframe with selected records.
Optional arguments:
tr=(t1,t2): select records that overlap with this timerange.