This module contains special classes and tools to handle oceanographic data.
An altimetry.data.hydro_data object dedicated to handling along-track altimetry data.
Example : | To load different sets of data, try these :
#Define parameters
trange_str = ['24/09/2012','05/09/2013']
trange,tdatetime=AT.cnes_convert(trange_str) #convert time range
alti_pattern = '/path/to/nrt/mfstep/nrt_mfstep_j2_sla_vfec_*.nc'
#Load data
alti=alti_data(alti_pattern,verbose=verbose,datatype='DT',time_range=trange,slaext=True) #Load data
#2D reordering of the data
alti.reorder()
#Plot results
pcolormesh(data.lat,data.cycle,data.sla); show() #plot the hovmoller
#Load data
alti_pattern = '/path/to/data/PISTACH_L3_Product_NWMED_MLE4_tr*_5hz.nc'
alti=alti_data(alti_pattern,limit=limit,verbose=verbose)
alti.create_Variable('sla', #new variable name
alti.ssh_mss_filtree_21pts, #data
{'time':alti._dimensions['time']}, #set dimensions
extend=False) #extend option
#get daily updates of the object
for date in xrange(21300,21320):
#get a deep copy of the object, not to erase the whole dataset
subset=alti.copy(deep=True)
#update the object with the proper slice
fg=subset.slice('date', [date,date+1])
subset.update(fg)
do_something(subset)
data=AD.alti_data('%s/*_2PTP*_*.nc' % RepData,verbose=opts.verbose,datatype='RAW',remove_existing=False)
data=AD.alti_data(fout,verbose=opts.verbose,datatype='RAW',transpose=False)
|
---|
returns a dataset from a single file or multiple concatenated files. cf. altimetry.data.hydro_data for further informations
Parameters: |
|
---|
Note
Naming convetion should respect AVISO formatting
return the list of cycles contained if the dataset
Compute the central time for each passes.
Note
this must be called AFTER having called altimetry.data.alti_data.reorder() as it looks for the CYCLE and RECORD dimensions.
Note
The methodology to compute the central time is to interpolate the time along the track at missing points, and then reading the value at point N/2.
reader method.
Parameters: |
|
---|
Note
This method is call from altimetry.data.hydro_data.__init__() and returns a data structure to be handled by altimetry.data.hydro_data.update_dataset()
Read AVISO Along-Track SLA regional products
Return outStr: | Output data structure containing all recorded parameters as specificied by NetCDF file PARAMETER list. |
---|---|
Author : | Renaud Dussurget |
data reader based on altimetry.tools.nctools.nc object.
Note
THIS can be VERY powerful!
Read AVISO Along-Track products
Return outStr: | Output data structure containing all recorded parameters as specificied by NetCDF file PARAMETER list. |
---|---|
Author : | Renaud Dussurget |
Read AVISO Along-Track SLAEXT regional products
Return outStr: | Output data structure containing all recorded parameters as specificied by NetCDF file PARAMETER list. |
---|---|
Author : | Renaud Dussurget |
Reorders data vectors in 2D (ie. with dimensions (CYCLE,RECORD)). This is useful to get a hovmoller-type matrix of each variable.
Example : | To plot a hovmoller for a given variable, do .. code-block:: pyhton
|
---|
Note
This only works for data reprojected along a nominal track.
set satellite name using (cf. notes on file names in altimetry.data.alti_data.__init__)
return the list of tracks contained if the dataset
A base object dedicated to handle oceanographic data (in-situ or remote sensing) with upper level processing methods.
Note
This object SHOULD NOT be called directly but through a subclass heritating of it (eg. altimetry.data.alti_data)
raises an exception
Returns the object filled with the data loaded from a single file or a concatenated set of files
Parameters: |
|
---|
Note
This methodes init all the attributes, then loads the data from files (altimetry.data.hydro_data.read()) and appends it to the object (altimetry.data.hydro_data.update_dataset()) before checking its content (altimetry.data.hydro_data.check_variables()).
Note
The method altimetry.data.hydro_data.read() MUST be defined (typically by overloading it). This method must return a data structure.
list of weak references to the object (if defined)
Forces variables to respect dimensions
shows a 2d space-depth section by interpolating the data along the section.
Note
This method interpolates using scipy.interpolate.griddata() and plots using matplotlib.pyplot.meshcolorgrid()
Returns a copy of the current data object
Parameters: |
|
---|
number of files loaded
Adds a dimension to class.
Parameters: |
|
---|
create_Variable : This function adds data to altimetry.data.hydro_data
Parameters: |
|
---|
Note
altimetry tools package handles the NetCDF data using specific structures.
NetCDF data is structured this way:
NetCDF_data = {'_dimensions':dimension_structure, #File dimensions (COMPULSORY)
'_attributes':attribute_structure, #Global attributes
'dimension_1':data_structure, #Data associated to the dimensions. (COMPULSORY)
...,
'variable_1':data_structure, #Variables
...
}
In standard NetCDF files, dimensions are always associated to a variable. If it is not the case, an array of indices the length of the dimension is generated and a warning is issued.
Moreover, dimensions MUST be defined to be accepted by altimetry.tools.nctools.nc (empty NetCDF files would fail).
dimension_structure = {'_ndims':N, #Attribute setting the number of dimensions.
'dims':{'dim_A':A, #Structure containing the name
'dim_B':B, #of the dimensions and their size.
...,
'dim_N':N
}
}
data_structure = {'attribute_1':attribute_1,
...,
'attribute_N':attribute_N}
data_structure = {'_dimensions':dimension_structure, #dimensions of hte variable (COMPULSORY)
'data':data, #data associated to the variable (COMPULSORY)
'long_name':long_name, #Variable attributes
'units':units,
...
}
DATA and _DIMENSIONS fields are compulsory. Other fields are optional and will be treated as attributes.
Furthermore, code will have a special look at scale, scale_factor and add_offset while reading and writing data and to _FillValue and missing_value while reading (_FillValue being automatically filled by NetCDF4.Dataset when writing)
pops a variable from class and delete it from parameter list
Parameters: | name – name of the parameter to delete |
---|
array containing the dimensions of each parameter
Directory name of the file pattern being globbed (glob.glob()). Defaulted to current directory
returns the limits of the dataset.
Parameters: |
|
---|
array of file IDs
list of files being loaded
number of counted values by files
retunrs a variable
returns the current dimensions of the object
returns a flag array of the data loaded from a given file pattern
Parameters: | pattern – pattern to match in the file list. |
---|
get some statistics about the whole dataset.
Parameters: | functype – set to ‘overall’ to get variables moments or ‘time’ to get temporal variability |
---|---|
Returns: | par_list, valid, per_valid, fname, trange, extent, N, avail_par, avail_par_per, par_stats |
Example : | par_list, valid, per_valid, fname, trange, extent, N, avail_par, avail_par_per, par_stats = self.get_object_stats() |
get statistics based on altimetry.data.hydro_data.id
Parameters: | functype – set to ‘overall’ to get variables moments or ‘time’|’temporal’ to get temporal variability |
---|
get some statistics about a part of the dataset
Parameters: |
|
---|---|
Returns: | If not FULL returs par_stats only (dict of dicts), else returns (par_list, valid, per_valid, fname, trange, extent, N, avail_par, avail_par_per, par_stats) |
Example : | par_list, valid, per_valid, fname, trange, extent, N, avail_par, avail_par_per, par_stats = self.stats(flag) |
get temporal statistics about a part of the dataset
Parameters: |
|
---|---|
Returns: | If not FULL returs par_stats only (dict of dicts), else returns (par_list, valid, per_valid, fname, trange, extent, N, avail_par, avail_par_per, par_stats) |
Example : | par_list, valid, per_valid, fname, trange, extent, N, avail_par, avail_par_per, par_stats = self.stats(flag) |
wrapper to altimetry.tools.in_limits() based on dataset limits.
limits of the domain : [latmin,lonmin,latmax,lonmax] (default = [-90.,0.,90.,360.])/
Note
limits are automatically reset using altimetry.tools.recale_limits()
display (or not) a map based on a altimetry.tools.plot_map object.
Parameters: | show – set to False not to show (and neither apply altimetry.tools.plot_map.setup_map()) |
---|
Note
This function creates a altimetry.tools.plot_map instance, plot a partion of the dataset using altimetry.data.hydro_data.plot_track() and displays it if asked to.
print function wrapper. Print a message depending on the verbose level
Parameters: | MSG_LEVEL ({in}{required}{type=int}) – level of the message to be compared with self.verbose |
---|---|
Example : | To write a message self.message(0,'This message will be shown for any verbose level')
|
returns a data structure (dict) of the dataset.
Parameters: | params – Add this keyword to provide a list of variables to export. Default : all variables contained is self.par_list |
---|
array of parameters
outputs a summary of the statistics for a given platform
plot trajectories based on platform IDs
Parameters: |
|
---|
Note
This method loops on data IDs. Then it calls altimetry.tools.plot_map.plot() or altimetry.tools.plot_map.scatter() to plot the trajectory and then labels the trajectory using altimetry.tools.plot_map.text()
plot a surface map of sampling track
Warning
DEPRECATED method!
shows a 2d space-depth section plotting point (using altimetry.tools.plot_map.scatter())
Example : | plot a temperature section along a glider transect |
---|
This is a wrapper to altimetry.data.hydro_data.delete_Variable()
append a data structure to an exisiting netcdf file
An Argo network NetCDF reader
Return outStr: | Output data stricture (dict) containing all recorded parameters as specificied by NetCDF file PARAMETER list. |
---|---|
Author : | Renaud Dussurget |
length of the dataset
get a flag for indexing based on values (ange of fixed values).
Parameters: |
|
---|
outputs a summary of the whole current dataset
Parameters: | functype – set to ‘overall’ to get variables moments or ‘time’ to get temporal variability |
---|
time range of the current dataset
Parameters: | flag – use a flag array to know the time range of an indexed slice of the object |
---|
slice object given a time range
Parameters: | timerange – rime range to be used. |
---|
Wrapper to altimetry.data.hydro_data.update_with_slice().
update a dimension by appending the number of added elements to the dimensions
<upddated dimension> = <old dimension> + <number of added elements along this dimension>
update class with a data structure.
Parameters: | flatten – use this to automatically flatten variables (squeeze dimensions) |
---|
update file indices attribute altimetry.data.hydro_data.fileid
update object with a given time slice flag
Parameters: | array) flag ((boolean) – a flag for indexing data along the ‘’time’’ dimension |
---|
Returns a sliced (updated) copy of current data object
Summary : | This has the same effect as obj.copy();obj.update(flag) but is much less memory consumming. |
---|
Note
TypeError could arise if some object attributes are setted outside the __init__() function (eg. for data objects derived from hydro_data). If this is the case, initialise these attributes within their respective __init__().
verbosity level on a scale of 0 (silent) to 4 (max verbosity)
Wrapper to warning.warn(). Returns a warning when verbose level is not 0.
Parameters: | MSG_LEVEL – level of the message to be compared with self.verbose |
---|---|
Example : | To issued a warning self.warning(1,'Warning being issued)
|
write a NetCDF file from current dataset
Parameters: | kwargs – additional arguments are passed to altimetry.tools.nctools.nc.write() |
---|