2.5.2.4. data.misc.profile – Management of profiles

Attributes:
  • POST_PLOT_ARGS
Classes:
Inheritance diagram:
 
digraph inheritance413a1c20a6 { rankdir=TB; ratio=compress; size="6.0, 8.0"; "vacumm.data.misc.dataset.Dataset" [URL="data.misc.dataset.html#vacumm.data.misc.dataset.Dataset",color=orange,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.6,shape=ellipse,style=filled,target="_top",tooltip="Generic dataset representation."]; "vacumm.misc.bases.Object" -> "vacumm.data.misc.dataset.Dataset" [arrowsize=0.5,penwidth=1,style="setlinewidth(0.5)"]; "vacumm.data.misc.dataset.OceanDataset" [URL="data.misc.dataset.html#vacumm.data.misc.dataset.OceanDataset",color=orange,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.6,shape=ellipse,style=filled,target="_top"]; "vacumm.data.misc.dataset.OceanSurfaceDataset" -> "vacumm.data.misc.dataset.OceanDataset" [arrowsize=0.5,penwidth=1,style="setlinewidth(0.5)"]; "vacumm.data.misc.dataset.OceanSurfaceDataset" [URL="data.misc.dataset.html#vacumm.data.misc.dataset.OceanSurfaceDataset",color=orange,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.6,shape=ellipse,style=filled,target="_top"]; "vacumm.data.misc.dataset.Dataset" -> "vacumm.data.misc.dataset.OceanSurfaceDataset" [arrowsize=0.5,penwidth=1,style="setlinewidth(0.5)"]; "vacumm.data.misc.profile.AbstractProfiles" [URL="#vacumm.data.misc.profile.AbstractProfiles",color=orange,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.6,shape=ellipse,style=filled,target="_top",tooltip="A Profile objects collection."]; "vacumm.misc.bases.Object" -> "vacumm.data.misc.profile.AbstractProfiles" [arrowsize=0.5,penwidth=1,style="setlinewidth(0.5)"]; "vacumm.data.misc.profile.Profile" [URL="#vacumm.data.misc.profile.Profile",color=orange,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.6,shape=ellipse,style=filled,target="_top",tooltip="A profile variables container."]; "vacumm.misc.bases.Object" -> "vacumm.data.misc.profile.Profile" [arrowsize=0.5,penwidth=1,style="setlinewidth(0.5)"]; "vacumm.data.misc.profile.Profiles" [URL="#vacumm.data.misc.profile.Profiles",color=orange,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.6,shape=ellipse,style=filled,target="_top",tooltip="Implementation of AbstractProfiles."]; "vacumm.data.misc.profile.AbstractProfiles" -> "vacumm.data.misc.profile.Profiles" [arrowsize=0.5,penwidth=1,style="setlinewidth(0.5)"]; "vacumm.data.misc.profile.ProfilesDataset" [URL="#vacumm.data.misc.profile.ProfilesDataset",color=orange,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.6,shape=ellipse,style=filled,target="_top",tooltip="Class for handling standardized profiles dataset as created by :meth:`Profiles.save`"]; "vacumm.data.misc.dataset.OceanDataset" -> "vacumm.data.misc.profile.ProfilesDataset" [arrowsize=0.5,penwidth=1,style="setlinewidth(0.5)"]; "vacumm.data.misc.profile.ProfilesDuplicatesFilter" [URL="#vacumm.data.misc.profile.ProfilesDuplicatesFilter",color=orange,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.6,shape=ellipse,style=filled,target="_top",tooltip="Split a profiles list into two profiles list:"]; "vacumm.data.misc.profile.ProfilesFilter" -> "vacumm.data.misc.profile.ProfilesDuplicatesFilter" [arrowsize=0.5,penwidth=1,style="setlinewidth(0.5)"]; "vacumm.data.misc.profile.ProfilesFilter" [URL="#vacumm.data.misc.profile.ProfilesFilter",color=orange,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.6,shape=ellipse,style=filled,target="_top"]; "vacumm.misc.bases.Object" -> "vacumm.data.misc.profile.ProfilesFilter" [arrowsize=0.5,penwidth=1,style="setlinewidth(0.5)"]; "vacumm.data.misc.profile.ProfilesMerger" [URL="#vacumm.data.misc.profile.ProfilesMerger",color=orange,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.6,shape=ellipse,style=filled,target="_top",tooltip="Hold a Profiles object which must be populated with the load method and then merged"]; "vacumm.misc.bases.Object" -> "vacumm.data.misc.profile.ProfilesMerger" [arrowsize=0.5,penwidth=1,style="setlinewidth(0.5)"]; "vacumm.data.misc.profile.ProfilesWithDepthFromPres" [URL="#vacumm.data.misc.profile.ProfilesWithDepthFromPres",color=orange,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.6,shape=ellipse,style=filled,target="_top",tooltip="A special Profiles type which forces trying to load depth from pressure first."]; "vacumm.data.misc.profile.Profiles" -> "vacumm.data.misc.profile.ProfilesWithDepthFromPres" [arrowsize=0.5,penwidth=1,style="setlinewidth(0.5)"]; "vacumm.data.misc.profile.Profiles_ArgoGeo" [URL="#vacumm.data.misc.profile.Profiles_ArgoGeo",color=orange,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.6,shape=ellipse,style=filled,target="_top",tooltip="Profils ARGO - Geo"]; "vacumm.data.misc.profile.ProfilesWithDepthFromPres" -> "vacumm.data.misc.profile.Profiles_ArgoGeo" [arrowsize=0.5,penwidth=1,style="setlinewidth(0.5)"]; "vacumm.data.misc.profile.Profiles_PR_BA" [URL="#vacumm.data.misc.profile.Profiles_PR_BA",color=orange,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.6,shape=ellipse,style=filled,target="_top",tooltip="Profils BATHY provenant du GTS"]; "vacumm.data.misc.profile.ProfilesWithDepthFromPres" -> "vacumm.data.misc.profile.Profiles_PR_BA" [arrowsize=0.5,penwidth=1,style="setlinewidth(0.5)"]; "vacumm.data.misc.profile.Profiles_PR_BO" [URL="#vacumm.data.misc.profile.Profiles_PR_BO",color=orange,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.6,shape=ellipse,style=filled,target="_top",tooltip="Profils Bouteilles"]; "vacumm.data.misc.profile.ProfilesWithDepthFromPres" -> "vacumm.data.misc.profile.Profiles_PR_BO" [arrowsize=0.5,penwidth=1,style="setlinewidth(0.5)"]; "vacumm.data.misc.profile.Profiles_PR_CT" [URL="#vacumm.data.misc.profile.Profiles_PR_CT",color=orange,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.6,shape=ellipse,style=filled,target="_top",tooltip="Profils CTD"]; "vacumm.data.misc.profile.ProfilesWithDepthFromPres" -> "vacumm.data.misc.profile.Profiles_PR_CT" [arrowsize=0.5,penwidth=1,style="setlinewidth(0.5)"]; "vacumm.data.misc.profile.Profiles_PR_PF" [URL="#vacumm.data.misc.profile.Profiles_PR_PF",color=orange,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.6,shape=ellipse,style=filled,target="_top",tooltip="Profils flotteurs Argo"]; "vacumm.data.misc.profile.ProfilesWithDepthFromPres" -> "vacumm.data.misc.profile.Profiles_PR_PF" [arrowsize=0.5,penwidth=1,style="setlinewidth(0.5)"]; "vacumm.data.misc.profile.Profiles_PR_RE" [URL="#vacumm.data.misc.profile.Profiles_PR_RE",color=orange,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.6,shape=ellipse,style=filled,target="_top",tooltip="Profils Recopesca"]; "vacumm.data.misc.profile.Profiles" -> "vacumm.data.misc.profile.Profiles_PR_RE" [arrowsize=0.5,penwidth=1,style="setlinewidth(0.5)"]; "vacumm.data.misc.profile.Profiles_PR_TE" [URL="#vacumm.data.misc.profile.Profiles_PR_TE",color=orange,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.6,shape=ellipse,style=filled,target="_top",tooltip="Profils TESAC provenant du GTS"]; "vacumm.data.misc.profile.ProfilesWithDepthFromPres" -> "vacumm.data.misc.profile.Profiles_PR_TE" [arrowsize=0.5,penwidth=1,style="setlinewidth(0.5)"]; "vacumm.data.misc.profile.Profiles_PR_XB" [URL="#vacumm.data.misc.profile.Profiles_PR_XB",color=orange,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.6,shape=ellipse,style=filled,target="_top",tooltip="Profils XBT ou XCTD"]; "vacumm.data.misc.profile.Profiles" -> "vacumm.data.misc.profile.Profiles_PR_XB" [arrowsize=0.5,penwidth=1,style="setlinewidth(0.5)"]; "vacumm.data.misc.profile.Profiles_Selmed" [URL="#vacumm.data.misc.profile.Profiles_Selmed",color=orange,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.6,shape=ellipse,style=filled,target="_top",tooltip="Profils utilises pour BOBYCLIM"]; "vacumm.data.misc.profile.ProfilesWithDepthFromPres" -> "vacumm.data.misc.profile.Profiles_Selmed" [arrowsize=0.5,penwidth=1,style="setlinewidth(0.5)"]; "vacumm.misc.bases.Object" [URL="misc.bases.html#vacumm.misc.bases.Object",color=orange,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.6,shape=ellipse,style=filled,target="_top",tooltip="Vacumm's base class proving common usefull features:"]; }

This module provides vertical profiles managers.

It is intented to be used with the two main goals:

  • convert various profiles, eventually merged, to a standardized format
  • operate on standardized profiles

The main classes are:

Two classes may be used as a program entry point using their main class method:

  • ProfilesMerger.main()

    • load profiles
    • save two profiles files: filtered (unique) and rejected (duplicates)
  • ProfilesDataset.main():

    • load a standardized profiles file
    • plot distribution, histogram and profile variables data
    • convert into a standardized profiles file format
class AbstractProfiles(*args, **kwargs)[source]

Bases: vacumm.misc.bases.Object, list

A Profile objects collection.

classmethod can_handle_dataset(*a, **k)[source]

Must be defined by implementing subclasses. Return a boolean indicating if a file can be handled by the concrete subclass.

critical = <bound class method AbstractProfiles.wrapper>
debug = <bound class method AbstractProfiles.wrapper>
error = <bound class method AbstractProfiles.wrapper>
exception = <bound class method AbstractProfiles.wrapper>
classmethod factory(*args, **kwargs)[source]

Create a Profiles object from nothing, a profile type, a profile dataset and/or profiles specification.

Examples:
>>> factory(type='PROFILE_TYPE_ID')
>>> factory(dataset='/path/to/dataset')
>>> factory(dataset='/path/to/dataset', type='PROFILE_TYPE')
>>> factory(dataset='/path/to/dataset', load=True)
>>> factory(dataset='/path/to/dataset', type='PROFILE_TYPE', load=True)

The dataset argument, if provided, is the dataset to use, either as a uri string, or CdmsFile. The type argument, if provided, is the profiles type identifier as returned by get_type. The load argument, if provided, indicate to load the provided file path.

get_default_variables(*a, **k)[source]

Must be defined by implementing subclasses. Return the list of strings indicating the default variables to be processed.

get_loglevel = <bound class method AbstractProfiles.wrapper>
classmethod get_type(*a, **k)[source]

Must be defined by implementing subclasses. This method must return a string identifier of the profile type

classmethod get_types()[source]

Return a dict of known profiles types as keys, implementing classes as values.

Available profiles types are based on this module AbstractProfiles implementation classes, with types determined by the get_type method.

Todo

  • add a way to plug external profiles types (from other modules)
classmethod get_variables_map()[source]

Must be defined by implementing subclasses. This method must return a dict with variables identifiers strings as keys, list of variables candidates strings as values.

info = <bound class method AbstractProfiles.wrapper>
is_debug = <bound class method AbstractProfiles.wrapper>
is_verbose = <bound class method AbstractProfiles.wrapper>
load_depth(*a, **k)[source]

Must be defined by implementing subclasses

load_filename(*a, **k)[source]

Must be defined by implementing subclasses

load_latitude(*a, **k)[source]

Must be defined by implementing subclasses

load_longitude(*a, **k)[source]

Must be defined by implementing subclasses

load_platform_code(*a, **k)[source]

Must be defined by implementing subclasses

load_pressure(*a, **k)[source]

Must be defined by implementing subclasses

load_time(*a, **k)[source]

Must be defined by implementing subclasses

load_variable(*a, **k)[source]

Must be defined by implementing subclasses

notice = <bound class method AbstractProfiles.wrapper>
notset = <bound class method AbstractProfiles.wrapper>
set_loglevel = <bound class method AbstractProfiles.wrapper>
verbose = <bound class method AbstractProfiles.wrapper>
warning = <bound class method AbstractProfiles.wrapper>
class Profile(**kwargs)[source]

Bases: vacumm.misc.bases.Object

A profile variables container. Store variables in a dictionnary with variables identifiers as keys, cdms variables as values. Variables must share the same profile properties: platform code, datetime, position and depth.

NOTE: At present, this loads (copy) all data in memory ..!

Required named argmuments:
 
  • platform_code: a string
  • datetime: datetime.datetime
  • latitude: float
  • longitude: float
  • datetime_corrupted: boolean indicating if the time component is corrupted (arbitrary set)
  • depth: cdms variable with shape (level)
  • variables: cdms variables dictionnary, variables with shape (level)
critical = <bound class method Profile.wrapper>
debug = <bound class method Profile.wrapper>
error = <bound class method Profile.wrapper>
exception = <bound class method Profile.wrapper>
get_depth_max()[source]

Return the maximum depth value.

get_depth_min()[source]

Return the minimum depth value.

get_depth_range()[source]

Return the depth range (min,max).

get_loglevel = <bound class method Profile.wrapper>
info = <bound class method Profile.wrapper>
is_debug = <bound class method Profile.wrapper>
is_verbose = <bound class method Profile.wrapper>
notice = <bound class method Profile.wrapper>
notset = <bound class method Profile.wrapper>
plot(variables=None, *args, **kwargs)[source]

Produce a 1D plot of the profile variable with depth as Y axis. :Params:

  • variables: optional list of strings used to restrict the variable to display
  • args, kwargs: passed to the underlying plot function
set_loglevel = <bound class method Profile.wrapper>
verbose = <bound class method Profile.wrapper>
warning = <bound class method Profile.wrapper>
class Profiles(profiles=[], **kwargs)[source]

Bases: vacumm.data.misc.profile.AbstractProfiles

Implementation of AbstractProfiles.

Define the load, get*, select and save features.

This class contains a variable_map attribute which is a dict with variables identifiers strings as keys, list of variables candidates strings as values. See load_variable for this mapping mecanism. Subclasses may modify this mapping attribute.

Params:
  • profiles: a list of Profile objects or Profiles instance or profiles file string.
  • spec: see below
  • the spec attributes below can also be passed directly as keyword arguments
If the spec attribute is provided, it must be an object (usually another Profiles instance) with the following attributes:
  • variables_map: the variable mapping, default to get_variables_map()
  • variables: identifiers of variables to be loaded, default is from get_default_variables()
  • qualities: quality codes filter, default is from get_default_variables()
  • time_units: time unit for internal time axis, default is ‘seconds since 1900-01-01 00:00:00’
Note:
  • When Profile or Profiles instances are given, their nested Profile objects are referenced, note copied.
Examples:
>>> import glob
>>> import vacumm.misc.axes as A
>>> import vacumm.data.misc.profile as P
>>> p = P.Profiles(
        profiles=glob.glob('argo-profiles-*.nc'),
        logger_level='debug',
        variables_map={
            'time':('TIME',),
            'depth':('DEPH',),
            'latitude':('LATITUDE',),
            'longitude':('LONGITUDE',),
            'temperature':('TEMP',),
            'salinity':('PSAL',),
        },
        variables=('temperature','salinity')
    )
>>> time = p.get_time()
>>> print 'time:', A.create_time(time, units=time.units).asComponentTime()
>>> print 'depth:', p.describe(p.get_depth(), stats=True)
>>> print 'latitude:', p.describe(p.get_latitude(), stats=True)
>>> print 'longitude:', p.describe(p.get_longitude(), stats=True)
>>> temp = p.get_variable('temperature')
>>> print 'temperature:', p.describe(temp, stats=True)
>>> psal = p.get_variable('salinity')
>>> print 'salinity:', p.describe(psal, stats=True)

Todo

  • fix load of single depth profile file
  • check depth quality test
classmethod can_handle_dataset(dataset)[source]

Return True if this class can handle the profiles of the given dataset. If dataset is a AbstractProfiles object, check that types matches. Else check that the type identifier is contained in the dataset file path, case insensitive (e.g. ‘/path/to/profiles_pr_ba_xxxx.nc’ and type is ‘pr_ba’)

critical = <bound class method Profiles.wrapper>
debug = <bound class method Profiles.wrapper>
default_time_units = 'seconds since 1900-01-01 00:00:00'
default_variables_map = {'depth': ['deph', 'depth'], 'depth_qc': ['depth_qc', 'pres_qc'], 'latitude': ['latitude'], 'longitude': ['longitude'], 'platform_code': ['platform_code'], 'position_qc': ['position_qc'], 'pressure': ['pressure', 'pres'], 'salinity': ['salinity', 'psal'], 'temperature': ['temperature', 'temp'], 'time': ['time', 'juld'], 'time_qc': ['time_qc', 'juld_qc']}
error = <bound class method Profiles.wrapper>
exception = <bound class method Profiles.wrapper>
classmethod get_default_qualities()[source]

Return the quality code this class would filter by default

classmethod get_default_variables()[source]

Return the variables identifiers this class should load by default

get_depth()[source]

Return the depth cdms variable of the nested profiles

get_depth_max()[source]

Get the maxnimum depth value

get_depth_min()[source]

Get the minimum depth value

get_depth_range()[source]

Get depth min and max

get_lat_max()[source]

Get the maximum latitude value

get_lat_min()[source]

Get the minimum latitude value

get_lat_range()[source]

Get lat min and max

get_latitude()[source]

Return the latitude cdms variable of the nested profiles

get_level_axis()[source]

Return the level cdms axis of the nested profiles

get_loglevel = <bound class method Profiles.wrapper>
get_lon_max()[source]

Get the maximum longitude value

get_lon_min()[source]

Get the minimum longitude value

get_lon_range()[source]

Get lon min and max

get_longitude()[source]

Return the longitude cdms variable of the nested profiles

get_origin_filename()[source]

Return the filename cdms variable of the nested profiles

get_platform_code()[source]

Return the platform code cdms variable of the nested profiles, if suitable, None otherwise

get_profile_axis()[source]

Return the profile cdms axis of the nested profiles

get_time()[source]

Return the time cdms variable of the nested profiles

get_time_max()[source]

Get the maximum date of nested profiles as a datetime object

get_time_min()[source]

Get the minimum date of nested profiles as a datetime object

get_time_range()[source]

Get time min and max

classmethod get_type()[source]

Return the profiles type identifier, used by get_types()

get_variable(varname)[source]

Return the varname (identifier) cdms variable of the nested profiles

classmethod get_variables_map()[source]

Return a copy of variable_map

info = <bound class method Profiles.wrapper>
is_debug = <bound class method Profiles.wrapper>
is_verbose = <bound class method Profiles.wrapper>
load(dataset, **kwargs)[source]

Load a dataset.

This loads a dataset or list of datasets and process quality filtering.

Params:
  • dataset: instance or list of instance of string (path) or CdmsFile
  • variables: variable identifiers to be loaded, defaults to self.variables
  • qualities: qualitie codes for filtering, defaults to self.qualities
  • timerange: if present, a time range for accepted profiles, defaults to self.timerange
  • lonrange: if present, a longitude range for accepted profiles, defaults to self.lonrange
  • latrange: if present, a latitude range for accepted profiles, defaults to self.latrange
Note:

this load all data into memory !

load_depth(dataset, *args, **kwargs)[source]

Load and return the depth variable (using load_variable())

Params:
  • tryconv: if true, try to convert pressure to depth if depth cannot be loaded
  • frompres: force pressure to depth conversion
load_depth_quality(dataset, *args, **kwargs)[source]

Load and return the depth quality variable (using variable_map)

load_filename(dataset)[source]

Load and return the filename

load_latitude(dataset, *args, **kwargs)[source]

Load and return the latitude variable (using load_variable())

load_longitude(dataset, *args, **kwargs)[source]

Load and return the longitude variable (using load_variable())

load_platform_code(dataset, *args, **kwargs)[source]

Load and return the platform code variable (using load_variable())

load_position_quality(dataset, *args, **kwargs)[source]

Load and return the position quality variable (using load_variable())

load_pressure(dataset, *args, **kwargs)[source]

Load and return the pressure variable (using load_variable())

Params:
  • tryconv: if true, try to convert depth to pressure if depth cannot be loaded
  • frompres: force depth to pressure conversion
load_time(dataset, *args, **kwargs)[source]

Load and return the time variable as an axis (using load_variable())

An extra keyword arguments getcflag indicates if the date corrupted flag must also be returned

load_time_quality(dataset, *args, **kwargs)[source]

Load and return the time quality variable (using load_variable())

load_variable(dataset, varid, *args, **kwargs)[source]

Load a variable

Params:
  • dataset: a CdmsFile object
  • varid: variable identifier
  • as_axis: if True, convert the loaded (1D) variable into a csdms axis
notice = <bound class method Profiles.wrapper>
notset = <bound class method Profiles.wrapper>
save(filepath, **kwargs)[source]

Save profiles in a netcdf file. :Params:

  • filepath: output netcdf file path
  • variables: list of variable identifiers to be saved, default is self.variables
select(variables=None, time=None, polys=None, **kwargs)[source]

Return a new Profiles instance (profiles are still referenced) of selected profiles.

Params:-variables: variables identifiers filtering -time: time filtering, see is_time_in_range() -polys: list of polygons (_geoslib.Polygon) for position filtering
set_loglevel = <bound class method Profiles.wrapper>
sort(cmp=None, *args, **kwargs)[source]

Sort profiles. :Params:

  • cmp: If a string, use a predifined sort behavior in:
    • ‘time’: Sort the nested profiles based on their datetime

Other parameters passed to the original sort method

summary()[source]

Return a summary string of nested profiles.

verbose = <bound class method Profiles.wrapper>
warning = <bound class method Profiles.wrapper>
class ProfilesDataset(dataset=None, time=None, lon=None, lat=None, level=None, ncobj_specs=None, nopat=False, patfreq=None, patfmtfunc=None, sort=True, check=True, **kwargs)[source]

Bases: vacumm.data.misc.dataset.OceanDataset

Class for handling standardized profiles dataset as created by Profiles.save()

Todo

  • allow to load files with different depth size
critical = <bound class method ProfilesDataset.wrapper>
debug = <bound class method ProfilesDataset.wrapper>
error = <bound class method ProfilesDataset.wrapper>
exception = <bound class method ProfilesDataset.wrapper>
get_axis(axname, select=None)[source]

Retreive a 1D or 2D axis.

Params:
  • name: Generic axis name.
  • select optional: Selection along this axis. Only slices are accepted for 2D axes.
  • select2 optional: Selection on the other dimension for 2D axes.
  • dataset optional: find axis based on this dataset.
  • getid, optional: If True, only return the id (netcdf name) or None.
  • warn, optional: Display a warning in case of problem.
  • searchmode, optional: Search order (see ncfind_obj()).
  • format, optional: Format the axis using format_axis()?
Return:
  • cdms2 axis or None if not found, or id
get_depth(time=None, level=None, lat=None, lon=None, squeeze=False, order=None, asvar=None, at=None, format=None, torect=True, verbose=None, warn=None, mode=None, **kwargs)[source]

Read the depth [m]

Params:
  • time/level/lat/lon, optional: For selection (tuples or slices).

  • squeeze, optional: Squeeze singleton dimensions (see squeeze_variable(), like True, z or ['x','y']).

  • mode, optional: Computing mode

    • None: Try all modes, in the following order.
    • "var": Read it from a variable.
    • "sigma": Estimate from sigma coordinates.
    • "dz": Estimate from layer thinknesses (see get_dz())
    • "axis": Read it from an axis (if not sigma coordinates)

    You can specifiy a list of them: ['dz', 'sigma'] You can also negate the search with a ‘-‘ sigme before: "-dz".

  • asvar, optional: Grow variable to match the asvar variable, using grow_variables().

  • asvar, optional: Reshape as this variable.

  • at, optional: Interpolate to this grid location using Datatset.toloc().

  • format, optional: Format the variable and its axes using format_var().

  • torect, optional: If possible, convert a curvilinear grid to a rectilinar grid using curv2rect().

  • order, optional: Change order of axes (like 'xty').

  • Other keywords are passed to ncread_files().

get_hist(tstep, **kwargs)[source]

Get histogram data.

Params:
  • tstep: bars time coverage (n,units) (ex: 1,’month’)
  • kwargs: passed to get_time()
get_latitude(**kwargs)[source]

Get latitude axis

get_layer(varname, depth, select=None)[source]

Get layer data for a specified depth.

Params:
  • variable: variable name
  • depth: layer depth
  • select: selector
get_loglevel = <bound class method ProfilesDataset.wrapper>
get_longitude(**kwargs)[source]

Get longitude axis

get_mld(select)[source]

Get mixed layer depth

MLD is computed for each selected profiles

Params:
  • select: selector
Return:
  • mld with shape (profile,)
  • lat with shape (profile,)
  • lon with shape (profile,)
get_origin_filename(**kwargs)[source]
get_ped(select)[source]

Get potential energy deficit

PED is computed for each selected profiles

Params:
  • select: selector
Return:
  • ped with shape (profile,)
  • lat with shape (profile,)
  • lon with shape (profile,)
get_platform_code(**kwargs)[source]
get_stratification_data(select)[source]

Get stratification data

Params:
  • select: selector
Return:
  • time, lat, lon, depth, depthimax, deltadepth, temp, sal, dens, densmin, densmax, densmean with shape (profile,)
get_time(**kwargs)[source]

Load time axis in a best time serie fashion.

Params:
  • time: time selector
get_variable(varname, select=None, squeeze=False)[source]

Load a variable in a best time serie fashion.

Params:
  • varname: Either a generic variable name listed in CF_VAR_SPECS, a netcdf name with a ‘+’ a prefix, a tuple of netcdf variable names or dictionnary of specification names with a search argument of ncfind_var() (tuple of netcdf names or dictionary).
  • time/lon/lat/level: Selector components.
  • squeeze: If true, call squeeze_variable() on the returned variable.
  • order: If not None, specify the output variable axes order.
  • depthup: Make depths up.
  • torect: Make grid rectangular if possible.
  • at/toloc: Interpolate the variable to another location on the grid using toloc(). Note that the arakawa_grid_type must be defined.
  • format: Format the variable and its axes using format_var()?
  • warn: Display a warning message if the variable can”t be retreived.
  • Other kwargs are passed to ncread_files().
Return:

cdms2 variable or None if not found

Example:
>>> get_variable('ssh', lon=(-10,0))
>>> get_variable('+xe')
>>> get_variable(dict(search={'standard_name':'sea_surface_height_above_sea_level'}))
info = <bound class method ProfilesDataset.wrapper>
is_debug = <bound class method ProfilesDataset.wrapper>
is_verbose = <bound class method ProfilesDataset.wrapper>
classmethod main(*args, **kwargs)[source]

Entry point of the bin/profile.py script. See profile.py - -help.

Params:
  • args and kwargs: passed to optparse.OptionParser.parse_args

Note

  • You may pass the “args” named argument to override command line arguments
Examples:
>>> ProfilesDataset.main(args=('myprofiles.nc', '--pro', '0,1,2'))
notice = <bound class method ProfilesDataset.wrapper>
notset = <bound class method ProfilesDataset.wrapper>
plot_dist(polygons=None, drawpro='x', drawpol=True, drawcnt=True, **kwargs)[source]

Produce a map of profiles distribution.

The polygons variable determine the plot mode:
  • if None, only profiles positions are drawn
  • otherwise, distribution is represented using colors for each specified polygon
Params:
  • polygons: list of distribution polygon (of type _geoslib.Polygon). Activate colored distribution if not None.
  • drawpro: symbol identifier of profiles (profiles not plotted if None)
  • drawpol: draw polygons contours if True
  • drawcnt: show textual profiles counts if True
Keyword arguments:
 
  • plot_<keyword>: are passed to the plot function map2()
plot_hist(*args, **kwargs)[source]

Produce a histogram plot.

Keyword arguments:
 
  • plot_<keyword>: are passed to the plot function bar2()

Other arguments, see get_hist()

plot_layer(varname, depth, *args, **kwargs)[source]

Plot a layer for a specified depth.

See get_layer()

plot_mld(select, **kwargs)[source]

Produce mixed layer depth map.

Params:

see get_mld()

Plot params:
  • map_<keyword>: are passed to the map plot function map2() excepting those about post plotting described below
  • plot_[show|close|savefig|savefigs]: are passed to the post plotting function post_plot() at end of plotting operations
plot_ped(select, **kwargs)[source]

Produce potential energy deficit map.

Params:

see get_ped()

Plot params:
  • map_<keyword>: are passed to the map plot function map2() excepting those about post plotting described below
  • plot_[show|close|savefig|savefigs]: are passed to the post plotting function post_plot() at end of plotting operations
plot_pro(varname, *index, **kwargs)[source]

Produce a 1D plot of the profiles with depth as Y axis.

Params:
  • varname: variable name
  • index: profile(s) indexe(s) (after optionnal selection)
Keyword arguments:
 
  • select: selector
  • plot_<keyword>: are passed to the plot function curve2()
set_loglevel = <bound class method ProfilesDataset.wrapper>
verbose = <bound class method ProfilesDataset.wrapper>
warning = <bound class method ProfilesDataset.wrapper>
class ProfilesDuplicatesFilter(maxtimedelta=43200, **kwargs)[source]

Bases: vacumm.data.misc.profile.ProfilesFilter

Split a profiles list into two profiles list:
  • a list of unique profile (filtered)
  • a list of duplicated profiles (rejected)
The duplication criterias are based on the equality of the profile’s attributes:
  • platform code
  • latitude and longitude
  • datetime

The profiles datetime must be flagged with a datetime_corrupted attribute indicating if the time component of the datetime atribute is reliable (False) or has been arbitrary set to 12H (True). In this case, two profiles are duplicates if the timedelta between their datetimes is less than maxtimedelta.

critical = <bound class method ProfilesDuplicatesFilter.wrapper>
debug = <bound class method ProfilesDuplicatesFilter.wrapper>
error = <bound class method ProfilesDuplicatesFilter.wrapper>
exception = <bound class method ProfilesDuplicatesFilter.wrapper>
filter(profiles)[source]

Filter profiles, split them into two list of filtered (unique) and rejected (duplicates). :Params:

  • profiles: A Profiles instance to be filtered
Return:
  • filtered: A Profiles instance
  • rejected: A Profiles instance
Note:

The returned profiles are initialized with the same input profiles specification.

get_loglevel = <bound class method ProfilesDuplicatesFilter.wrapper>
info = <bound class method ProfilesDuplicatesFilter.wrapper>
is_debug = <bound class method ProfilesDuplicatesFilter.wrapper>
is_duplicate(pro1, pro2)[source]

Return a boolean indicating if pro1 and pro2 are considered duplicates.

is_verbose = <bound class method ProfilesDuplicatesFilter.wrapper>
notice = <bound class method ProfilesDuplicatesFilter.wrapper>
notset = <bound class method ProfilesDuplicatesFilter.wrapper>
set_loglevel = <bound class method ProfilesDuplicatesFilter.wrapper>
verbose = <bound class method ProfilesDuplicatesFilter.wrapper>
warning = <bound class method ProfilesDuplicatesFilter.wrapper>
class ProfilesFilter(**kwargs)[source]

Bases: vacumm.misc.bases.Object

critical = <bound class method ProfilesFilter.wrapper>
debug = <bound class method ProfilesFilter.wrapper>
error = <bound class method ProfilesFilter.wrapper>
exception = <bound class method ProfilesFilter.wrapper>
filter(*args, **kwargs)[source]

Must be defined by implementing subclasses This method must return two Profiles instances (filtered and rejected)

get_loglevel = <bound class method ProfilesFilter.wrapper>
info = <bound class method ProfilesFilter.wrapper>
is_debug = <bound class method ProfilesFilter.wrapper>
is_verbose = <bound class method ProfilesFilter.wrapper>
notice = <bound class method ProfilesFilter.wrapper>
notset = <bound class method ProfilesFilter.wrapper>
set_loglevel = <bound class method ProfilesFilter.wrapper>
verbose = <bound class method ProfilesFilter.wrapper>
warning = <bound class method ProfilesFilter.wrapper>
class ProfilesMerger(spec=None, **kwargs)[source]

Bases: vacumm.misc.bases.Object

Hold a Profiles object which must be populated with the load method and then merged with the merge method.

critical = <bound class method ProfilesMerger.wrapper>
debug = <bound class method ProfilesMerger.wrapper>
error = <bound class method ProfilesMerger.wrapper>
exception = <bound class method ProfilesMerger.wrapper>
get_loglevel = <bound class method ProfilesMerger.wrapper>
info = <bound class method ProfilesMerger.wrapper>
is_debug = <bound class method ProfilesMerger.wrapper>
is_verbose = <bound class method ProfilesMerger.wrapper>
load(dataset, **kwargs)[source]

Add profile(s) to the internal instance. :Params:

classmethod main(args=None)[source]

Entry point of the bin/merge_profiles.py script. See merge_profiles.py –help.

Params:
  • args: passed to config.ConfigManager.opt_parse

Note

  • You may pass the “args” argument to override command line arguments
Examples:
>>> ProfilesMerger.main(args='--cfgfile myconf.cfg --verbose --ProfilesMerger-load-timerange "2010-01-01 2010-03-31"'.split())
merge(filter=None, filter_file=None, reject_file=None, filter_sort=None, reject_sort=None, **kwargs)[source]

Merge the profiles applying a filter originally designed to seperate duplicate profiles. See ProfilesDuplicatesFilter. :Params:

  • filter: the filter class to be used
  • filter_file: optionnal, string, the filtered profiles output file path
  • reject_file: optionnal, string, the filtered profiles output file path
  • filter_sort: optional, string, see Profiles.sort()
  • reject_sort: optional, string, see Profiles.sort()
notice = <bound class method ProfilesMerger.wrapper>
notset = <bound class method ProfilesMerger.wrapper>
set_loglevel = <bound class method ProfilesMerger.wrapper>
verbose = <bound class method ProfilesMerger.wrapper>
warning = <bound class method ProfilesMerger.wrapper>
class ProfilesWithDepthFromPres(profiles=[], **kwargs)[source]

Bases: vacumm.data.misc.profile.Profiles

A special Profiles type which forces trying to load depth from pressure first.

critical = <bound class method ProfilesWithDepthFromPres.wrapper>
debug = <bound class method ProfilesWithDepthFromPres.wrapper>
error = <bound class method ProfilesWithDepthFromPres.wrapper>
exception = <bound class method ProfilesWithDepthFromPres.wrapper>
get_loglevel = <bound class method ProfilesWithDepthFromPres.wrapper>
info = <bound class method ProfilesWithDepthFromPres.wrapper>
is_debug = <bound class method ProfilesWithDepthFromPres.wrapper>
is_verbose = <bound class method ProfilesWithDepthFromPres.wrapper>
load_depth(dataset, *args, **kwargs)[source]

Load and return the depth variable (using load_variable())

Params:
  • tryconv: if true, try to convert pressure to depth if depth cannot be loaded
  • frompres: force pressure to depth conversion
notice = <bound class method ProfilesWithDepthFromPres.wrapper>
notset = <bound class method ProfilesWithDepthFromPres.wrapper>
set_loglevel = <bound class method ProfilesWithDepthFromPres.wrapper>
verbose = <bound class method ProfilesWithDepthFromPres.wrapper>
warning = <bound class method ProfilesWithDepthFromPres.wrapper>
class Profiles_ArgoGeo(profiles=[], **kwargs)[source]

Bases: vacumm.data.misc.profile.ProfilesWithDepthFromPres

Profils ARGO - Geo

critical = <bound class method Profiles_ArgoGeo.wrapper>
debug = <bound class method Profiles_ArgoGeo.wrapper>
error = <bound class method Profiles_ArgoGeo.wrapper>
exception = <bound class method Profiles_ArgoGeo.wrapper>
get_loglevel = <bound class method Profiles_ArgoGeo.wrapper>
classmethod get_type()[source]

Return the profiles type identifier, used by get_types()

classmethod get_variables_map()[source]

Return a copy of variable_map

info = <bound class method Profiles_ArgoGeo.wrapper>
is_debug = <bound class method Profiles_ArgoGeo.wrapper>
is_verbose = <bound class method Profiles_ArgoGeo.wrapper>
notice = <bound class method Profiles_ArgoGeo.wrapper>
notset = <bound class method Profiles_ArgoGeo.wrapper>
set_loglevel = <bound class method Profiles_ArgoGeo.wrapper>
verbose = <bound class method Profiles_ArgoGeo.wrapper>
warning = <bound class method Profiles_ArgoGeo.wrapper>
class Profiles_PR_BA(profiles=[], **kwargs)[source]

Bases: vacumm.data.misc.profile.ProfilesWithDepthFromPres

Profils BATHY provenant du GTS

critical = <bound class method Profiles_PR_BA.wrapper>
debug = <bound class method Profiles_PR_BA.wrapper>
error = <bound class method Profiles_PR_BA.wrapper>
exception = <bound class method Profiles_PR_BA.wrapper>
get_loglevel = <bound class method Profiles_PR_BA.wrapper>
classmethod get_type()[source]

Return the profiles type identifier, used by get_types()

classmethod get_variables_map()[source]

Return a copy of variable_map

info = <bound class method Profiles_PR_BA.wrapper>
is_debug = <bound class method Profiles_PR_BA.wrapper>
is_verbose = <bound class method Profiles_PR_BA.wrapper>
notice = <bound class method Profiles_PR_BA.wrapper>
notset = <bound class method Profiles_PR_BA.wrapper>
set_loglevel = <bound class method Profiles_PR_BA.wrapper>
verbose = <bound class method Profiles_PR_BA.wrapper>
warning = <bound class method Profiles_PR_BA.wrapper>
class Profiles_PR_BO(profiles=[], **kwargs)[source]

Bases: vacumm.data.misc.profile.ProfilesWithDepthFromPres

Profils Bouteilles

critical = <bound class method Profiles_PR_BO.wrapper>
debug = <bound class method Profiles_PR_BO.wrapper>
error = <bound class method Profiles_PR_BO.wrapper>
exception = <bound class method Profiles_PR_BO.wrapper>
get_loglevel = <bound class method Profiles_PR_BO.wrapper>
classmethod get_type()[source]

Return the profiles type identifier, used by get_types()

classmethod get_variables_map()[source]

Return a copy of variable_map

info = <bound class method Profiles_PR_BO.wrapper>
is_debug = <bound class method Profiles_PR_BO.wrapper>
is_verbose = <bound class method Profiles_PR_BO.wrapper>
notice = <bound class method Profiles_PR_BO.wrapper>
notset = <bound class method Profiles_PR_BO.wrapper>
set_loglevel = <bound class method Profiles_PR_BO.wrapper>
verbose = <bound class method Profiles_PR_BO.wrapper>
warning = <bound class method Profiles_PR_BO.wrapper>
class Profiles_PR_CT(profiles=[], **kwargs)[source]

Bases: vacumm.data.misc.profile.ProfilesWithDepthFromPres

Profils CTD

critical = <bound class method Profiles_PR_CT.wrapper>
debug = <bound class method Profiles_PR_CT.wrapper>
error = <bound class method Profiles_PR_CT.wrapper>
exception = <bound class method Profiles_PR_CT.wrapper>
get_loglevel = <bound class method Profiles_PR_CT.wrapper>
classmethod get_type()[source]

Return the profiles type identifier, used by get_types()

info = <bound class method Profiles_PR_CT.wrapper>
is_debug = <bound class method Profiles_PR_CT.wrapper>
is_verbose = <bound class method Profiles_PR_CT.wrapper>
notice = <bound class method Profiles_PR_CT.wrapper>
notset = <bound class method Profiles_PR_CT.wrapper>
set_loglevel = <bound class method Profiles_PR_CT.wrapper>
verbose = <bound class method Profiles_PR_CT.wrapper>
warning = <bound class method Profiles_PR_CT.wrapper>
class Profiles_PR_PF(profiles=[], **kwargs)[source]

Bases: vacumm.data.misc.profile.ProfilesWithDepthFromPres

Profils flotteurs Argo

critical = <bound class method Profiles_PR_PF.wrapper>
debug = <bound class method Profiles_PR_PF.wrapper>
error = <bound class method Profiles_PR_PF.wrapper>
exception = <bound class method Profiles_PR_PF.wrapper>
get_loglevel = <bound class method Profiles_PR_PF.wrapper>
classmethod get_type()[source]

Return the profiles type identifier, used by get_types()

classmethod get_variables_map()[source]

Return a copy of variable_map

info = <bound class method Profiles_PR_PF.wrapper>
is_debug = <bound class method Profiles_PR_PF.wrapper>
is_verbose = <bound class method Profiles_PR_PF.wrapper>
notice = <bound class method Profiles_PR_PF.wrapper>
notset = <bound class method Profiles_PR_PF.wrapper>
set_loglevel = <bound class method Profiles_PR_PF.wrapper>
verbose = <bound class method Profiles_PR_PF.wrapper>
warning = <bound class method Profiles_PR_PF.wrapper>
class Profiles_PR_RE(profiles=[], **kwargs)[source]

Bases: vacumm.data.misc.profile.Profiles

Profils Recopesca

critical = <bound class method Profiles_PR_RE.wrapper>
debug = <bound class method Profiles_PR_RE.wrapper>
error = <bound class method Profiles_PR_RE.wrapper>
exception = <bound class method Profiles_PR_RE.wrapper>
get_loglevel = <bound class method Profiles_PR_RE.wrapper>
classmethod get_type()[source]

Return the profiles type identifier, used by get_types()

info = <bound class method Profiles_PR_RE.wrapper>
is_debug = <bound class method Profiles_PR_RE.wrapper>
is_verbose = <bound class method Profiles_PR_RE.wrapper>
notice = <bound class method Profiles_PR_RE.wrapper>
notset = <bound class method Profiles_PR_RE.wrapper>
set_loglevel = <bound class method Profiles_PR_RE.wrapper>
verbose = <bound class method Profiles_PR_RE.wrapper>
warning = <bound class method Profiles_PR_RE.wrapper>
class Profiles_PR_TE(profiles=[], **kwargs)[source]

Bases: vacumm.data.misc.profile.ProfilesWithDepthFromPres

Profils TESAC provenant du GTS

critical = <bound class method Profiles_PR_TE.wrapper>
debug = <bound class method Profiles_PR_TE.wrapper>
error = <bound class method Profiles_PR_TE.wrapper>
exception = <bound class method Profiles_PR_TE.wrapper>
get_loglevel = <bound class method Profiles_PR_TE.wrapper>
classmethod get_type()[source]

Return the profiles type identifier, used by get_types()

info = <bound class method Profiles_PR_TE.wrapper>
is_debug = <bound class method Profiles_PR_TE.wrapper>
is_verbose = <bound class method Profiles_PR_TE.wrapper>
notice = <bound class method Profiles_PR_TE.wrapper>
notset = <bound class method Profiles_PR_TE.wrapper>
set_loglevel = <bound class method Profiles_PR_TE.wrapper>
verbose = <bound class method Profiles_PR_TE.wrapper>
warning = <bound class method Profiles_PR_TE.wrapper>
class Profiles_PR_XB(profiles=[], **kwargs)[source]

Bases: vacumm.data.misc.profile.Profiles

Profils XBT ou XCTD

critical = <bound class method Profiles_PR_XB.wrapper>
debug = <bound class method Profiles_PR_XB.wrapper>
error = <bound class method Profiles_PR_XB.wrapper>
exception = <bound class method Profiles_PR_XB.wrapper>
get_loglevel = <bound class method Profiles_PR_XB.wrapper>
classmethod get_type()[source]

Return the profiles type identifier, used by get_types()

info = <bound class method Profiles_PR_XB.wrapper>
is_debug = <bound class method Profiles_PR_XB.wrapper>
is_verbose = <bound class method Profiles_PR_XB.wrapper>
notice = <bound class method Profiles_PR_XB.wrapper>
notset = <bound class method Profiles_PR_XB.wrapper>
set_loglevel = <bound class method Profiles_PR_XB.wrapper>
verbose = <bound class method Profiles_PR_XB.wrapper>
warning = <bound class method Profiles_PR_XB.wrapper>
class Profiles_Selmed(profiles=[], **kwargs)[source]

Bases: vacumm.data.misc.profile.ProfilesWithDepthFromPres

Profils utilises pour BOBYCLIM

critical = <bound class method Profiles_Selmed.wrapper>
debug = <bound class method Profiles_Selmed.wrapper>
error = <bound class method Profiles_Selmed.wrapper>
exception = <bound class method Profiles_Selmed.wrapper>
get_loglevel = <bound class method Profiles_Selmed.wrapper>
classmethod get_type()[source]

Return the profiles type identifier, used by get_types()

classmethod get_variables_map()[source]

Return a copy of variable_map

info = <bound class method Profiles_Selmed.wrapper>
is_debug = <bound class method Profiles_Selmed.wrapper>
is_verbose = <bound class method Profiles_Selmed.wrapper>
notice = <bound class method Profiles_Selmed.wrapper>
notset = <bound class method Profiles_Selmed.wrapper>
set_loglevel = <bound class method Profiles_Selmed.wrapper>
verbose = <bound class method Profiles_Selmed.wrapper>
warning = <bound class method Profiles_Selmed.wrapper>