epygram.resources
— Real and virtual resources handling¶
Module contains:
resource for data contained in file (FileResource).
other resources built on top of FileResource:
MultiValiditiesResource: join several resources to furnish fields with temporal evolution;
CombineLevelsResource: from a resource containing 2D fields on adjacent levels, emulates a resource that provide 3D fields
a proxy function to build such meta resources
- class epygram.resources.open_and_close_resource(r)[source]¶
Bases:
object
Context manager for automatically open/close resources.
- Parameters
r – resource to open
- epygram.resources.meta_resource(filenames_or_resources, openmode, rtype)[source]¶
Factory for meta resources, such as MultiValiditiesResource or CombineLevelsResource.
- Parameters
filenames_or_resources – can be either a filename or a list of, or a resource or a list of.
openmode – among ‘r’, ‘w’, ‘a’
rtype –
resource type, e.g.:
’MV’ for a MultiValiditiesResource,
’CL’ for a CombineLevelsResource
’MV+CL’ for a composition of both (should be similar to CL+MV)
- class epygram.resources.FileResource(*args, **kwargs)[source]¶
Bases:
epygram.base.Resource
Generic abstract class implementing a Resource.
Note
This class is managed by footprint.
info: Not documented
priority: PriorityLevel::DEFAULT (rank=1)
Automatic parameters from the footprint:
filename (
builtins.str
) - rxx - File name (absolute or relative) of the resource.fmtdelayedopen (
builtins.bool
) - rxx - Opening of the resource delayed (not at time of construction).Optional. Default is False.
format (
builtins.str
) - rxx - Format of the resource.Optional. Default is None.
openmode (
builtins.str
) - rxx - Opening mode.Values: set([‘append’, ‘r’, ‘read’, ‘w’, ‘a’, ‘write’])
Remap: dict(append = ‘a’, read = ‘r’, write = ‘w’,)
Constructor. See its footprint for arguments.
- filename¶
File name (absolute or relative) of the resource (see the documentation above for more details).
- fmtdelayedopen¶
Opening of the resource delayed (not at time of construction) (see the documentation above for more details).
- format¶
Format of the resource (see the documentation above for more details).
- open(openmode=None)[source]¶
Opens the resource properly.
- Parameters
openmode – to open with a specific openmode, eventually different from
the one specified at initialization.
- openmode¶
Opening mode (see the documentation above for more details).
- class epygram.resources.MultiValiditiesResource(*args, **kwargs)[source]¶
Bases:
epygram.base.Resource
Class implementing a MultiValiditiesResource.
Note
This class is managed by footprint.
info: Not documented
priority: PriorityLevel::DEFAULT (rank=1)
Automatic parameters from the footprint:
name (
builtins.str
) - rxx - Not documented, sorry.Values: set([‘MultiValidities’])
openmode (
builtins.str
) - rxx - Opening mode.Values: set([‘append’, ‘r’, ‘read’, ‘w’, ‘a’, ‘write’])
Remap: dict(append = ‘a’, read = ‘r’, write = ‘w’,)
resources (
footprints.stdtypes.FPList
) - rxx - List of resources to join.
Constructor. See its footprint for arguments.
- extractprofile(*args, **kwargs)[source]¶
Extracts the profiles in the different resources and join the validities.
- extractsection(*args, **kwargs)[source]¶
Extracts the sections in the different resources and join the validities.
- name¶
(see the documentation above for more details).
- openmode¶
Opening mode (see the documentation above for more details).
- readfield(*args, **kwargs)[source]¶
Reads the field in the different resources and join the validities.
- resources¶
List of resources to join (see the documentation above for more details).
- property spectral_geometry¶
Returns the spectral_geometry
- class epygram.resources.CombineLevelsResource(*args, **kwargs)[source]¶
Bases:
epygram.base.Resource
Class implementing a CombineLevelsResource.
Note
This class is managed by footprint.
info: Not documented
priority: PriorityLevel::DEFAULT (rank=1)
Automatic parameters from the footprint:
name (
builtins.str
) - rxx - Not documented, sorry.Values: set([‘CombineLevels’])
openmode (
builtins.str
) - rxx - Opening mode.Values: set([‘append’, ‘r’, ‘read’, ‘w’, ‘a’, ‘write’])
Remap: dict(append = ‘a’, read = ‘r’, write = ‘w’,)
resource (
epygram.base.Resource
) - rxx - Low level resourcevirtual (
builtins.bool
) - rxx - Must readfield return a virtual fieldOptional. Default is False.
Constructor. See its footprint for arguments.
- find_fields_in_resource(seed=None, generic=False)[source]¶
Returns a list of the fields from resource whose name match the given seed.
- Parameters
seed – might be a ‘handgrip’, i.e. a dict where you can store all requested keys, e.g. {‘shortName’:’t’, ‘indicatorOfTypeOfLevel’:’pl’, ‘level’:850}, a list of handgrips or None. If None (default), returns the list of all fields in resource.
generic – if True, returns a list of tuples (fid, fid) of the fields (for mimetism with other formats).
- name¶
(see the documentation above for more details).
- openmode¶
Opening mode (see the documentation above for more details).
- readfield(handgrip, getdata=True)[source]¶
Read the field in the low level resource and join the levels.
- Parameters
handgrip – identification of the field
getdata – if False, do not read data but only metadata
- readfields(handgrip, getdata=True)[source]¶
Read the field in the low level resource and join the levels.
- Parameters
handgrip – identification of the field
getdata – if False, do not read data but only metadata
- resource¶
Low level resource (see the documentation above for more details).
- sortfields(sortingkey, onlykey=None)[source]¶
Returns a sorted list of fields with regards to the given sortingkey of their fid, as a dict of lists.
- Parameters
sortingkey – sorting key
onlykey – can be specified as a string or a tuple of strings, so that only specified keys of the fid will returned.
- property spectral_geometry¶
Returns the spectral_geometry
- virtual¶
Must readfield return a virtual field (see the documentation above for more details).