disdrodb.metadata package#
Submodules#
disdrodb.metadata.checks module#
Check metadata.
- disdrodb.metadata.checks.check_archive_metadata_campaign_name(base_dir: Optional[str] = None) bool [source]#
Check metadata
campaign_name
.- Parameters
base_dir (str (optional)) – Base directory of DISDRODB. Format:
<...>/DISDRODB
. IfNone
(the default), thebase_dir
path specified in the DISDRODB active configuration will be used.- Returns
If the check succeeds, the result is
True
, otherwiseFalse
.- Return type
bool
- disdrodb.metadata.checks.check_archive_metadata_compliance(base_dir: Optional[str] = None, raise_error=False)[source]#
Check the archive metadata compliance.
- Parameters
base_dir (str (optional)) – Base directory of DISDRODB. Format:
<...>/DISDRODB
. IfNone
(the default), thebase_dir
path specified in the DISDRODB active configuration will be used.raise_error (bool (optional)) – Whether to raise an error and interrupt the archive check if a metadata is not compliant. The default is
False
.
- Returns
If the check succeeds, the result is
True
, otherwiseFalse
.- Return type
bool
- disdrodb.metadata.checks.check_archive_metadata_data_source(base_dir: Optional[str] = None) bool [source]#
Check metadata
data_source
.- Parameters
base_dir (str (optional)) – Base directory of DISDRODB. Format:
<...>/DISDRODB
. IfNone
(the default), thebase_dir
path specified in the DISDRODB active configuration will be used.- Returns
If the check succeeds, the result is
True
, otherwiseFalse
.- Return type
bool
- disdrodb.metadata.checks.check_archive_metadata_geolocation(base_dir: Optional[str] = None)[source]#
Check the metadata files have missing or wrong geolocation..
- Parameters
base_dir (str (optional)) – Base directory of DISDRODB. Format:
<...>/DISDRODB
. IfNone
(the default), thebase_dir
path specified in the DISDRODB active configuration will be used.- Returns
If the check succeeds, the result is
True
, otherwiseFalse
.- Return type
bool
- disdrodb.metadata.checks.check_archive_metadata_keys(base_dir: Optional[str] = None) bool [source]#
Check that all metadata files have valid keys.
- Parameters
base_dir (str (optional)) – Base directory of DISDRODB. Format:
<...>/DISDRODB
IfNone
(the default), the disdrodb config keybase_dir
is used.- Returns
If the check succeeds, the result is
True
, otherwiseFalse
.- Return type
bool
- disdrodb.metadata.checks.check_archive_metadata_reader(base_dir: Optional[str] = None) bool [source]#
Check if the
reader
key is available and there is the associated reader.- Parameters
base_dir (str (optional)) – Base directory of DISDRODB. Format:
<...>/DISDRODB
. IfNone
(the default), thebase_dir
path specified in the DISDRODB active configuration will be used.- Returns
If the check succeeds, the result is
True
, otherwiseFalse
.- Return type
bool
- disdrodb.metadata.checks.check_archive_metadata_sensor_name(base_dir: Optional[str] = None) bool [source]#
Check metadata
sensor_name
.- Parameters
base_dir (str (optional)) – Base directory of DISDRODB. Format:
<...>/DISDRODB
. IfNone
(the default), thebase_dir
path specified in the DISDRODB active configuration will be used.- Returns
If the check succeeds, the result is
True
, otherwiseFalse
.- Return type
bool
- disdrodb.metadata.checks.check_archive_metadata_station_name(base_dir: Optional[str] = None) bool [source]#
Check metadata
station_name
.- Parameters
base_dir (str (optional)) – Base directory of DISDRODB. Format:
<...>/DISDRODB
. IfNone
(the default), thebase_dir
path specified in the DISDRODB active configuration will be used.- Returns
If the check succeeds, the result is
True
, otherwiseFalse
.- Return type
bool
- disdrodb.metadata.checks.check_metadata_compliance(data_source, campaign_name, station_name, base_dir=None, product='RAW')[source]#
Check DISDRODB metadata compliance.
- disdrodb.metadata.checks.check_metadata_geolocation(metadata) None [source]#
Identify metadata with missing or wrong geolocation.
- disdrodb.metadata.checks.get_metadata_invalid_keys(metadata)[source]#
Return the DISDRODB metadata keys which are not valid.
- disdrodb.metadata.checks.get_metadata_missing_keys(metadata)[source]#
Return the DISDRODB metadata keys which are missing.
disdrodb.metadata.info module#
Test Metadata Info Extraction.
- disdrodb.metadata.info.get_archive_metadata_key_value(key: str, return_tuple: bool = True, base_dir: Optional[str] = None)[source]#
Return the values of a metadata key for all the archive.
- Parameters
base_dir (str (optional)) – Path to the disdrodb directory.
key (str) – Metadata key.
return_tuple (bool, optional) – If
True
, returns a tuple (data_source
,``campaign_name``,``station_name``,key_value
) IfFalse
, returns a list of the key values. The default isTrue
.base_dir – Base directory of DISDRODB. Format:
<...>/DISDRODB
. IfNone
(the default), thebase_dir
path specified in the DISDRODB active configuration will be used.
- Returns
List or tuple of values of the metadata key.
- Return type
list or tuple
disdrodb.metadata.manipulation module#
Metadata Manipulation Tools.
- disdrodb.metadata.manipulation.add_missing_metadata_keys(metadata)[source]#
Add missing keys to the metadata dictionary.
disdrodb.metadata.reader module#
Routines to read the DISDRODB Metadata.
- disdrodb.metadata.reader.read_station_metadata(data_source, campaign_name, station_name, base_dir=None, product='RAW')[source]#
Open the station metadata YAML file into a dictionary.
- Parameters
data_source (str) – The name of the institution (for campaigns spanning multiple countries) or the name of the country (for campaigns or sensor networks within a single country). Must be provided in UPPER CASE.
campaign_name (str) – The name of the campaign. Must be provided in UPPER CASE.
station_name (str) – The name of the station.
base_dir (str, optional) – The base directory of DISDRODB, expected in the format
<...>/DISDRODB
. If not specified, the path specified in the DISDRODB active configuration will be used.product (str, optional) – The DISDRODB product in which to search for the metadata file. The default is
"RAW"
.
- Returns
metadata – The station metadata dictionary
- Return type
dictionary
disdrodb.metadata.search module#
Routines to manipulate the DISDRODB Metadata Archive.
- disdrodb.metadata.search.get_list_metadata(data_sources=None, campaign_names=None, station_names=None, with_stations_data=True, base_dir=None)[source]#
Get the list of metadata filepaths in the DISDRODB raw archive.
- Parameters
data_sources (str or list of str) – Name of data source(s) of interest. The name(s) must be UPPER CASE. The default is
None
.campaign_names (str or list of str) – Name of the campaign(s) of interest. The name(s) must be UPPER CASE. The default is
None
.station_names (str or list of str) – Station names of interest. The default is
None
.with_stations_data (bool) – If
True
, only return metadata filepaths that have corresponding data in the local DISDRODB raw archive. The default isTrue
.base_dir (str (optional)) – Base directory of DISDRODB. Format:
<...>/DISDRODB
. IfNone
(the default), thebase_dir
path specified in the DISDRODB active configuration will be used.
- Returns
metadata_filepaths – List of metadata YAML file paths
- Return type
list
disdrodb.metadata.standards module#
Define DISDRODB Metadata Standards.
disdrodb.metadata.writer module#
Routines to write the DISDRODB Metadata.
- disdrodb.metadata.writer.create_station_metadata(data_source, campaign_name, station_name, base_dir=None, product='RAW')[source]#
Write a default (semi-empty) YAML metadata file for a DISDRODB station.
An error is raised if the file already exists !
- Parameters
data_source (str) – The name of the institution (for campaigns spanning multiple countries) or the name of the country (for campaigns or sensor networks within a single country). Must be provided in UPPER CASE.
campaign_name (str) – The name of the campaign. Must be provided in UPPER CASE.
station_name (str) – The name of the station.
base_dir (str, optional) – The base directory of DISDRODB, expected in the format
<...>/DISDRODB
. If not specified, the path specified in the DISDRODB active configuration will be used.product (str, optional) – The DISDRODB product in which to search for the metadata file. The default is
"RAW"
.
Module contents#
- disdrodb.metadata.get_archive_metadata_key_value(key: str, return_tuple: bool = True, base_dir: Optional[str] = None)[source]#
Return the values of a metadata key for all the archive.
- Parameters
base_dir (str (optional)) – Path to the disdrodb directory.
key (str) – Metadata key.
return_tuple (bool, optional) – If
True
, returns a tuple (data_source
,``campaign_name``,``station_name``,key_value
) IfFalse
, returns a list of the key values. The default isTrue
.base_dir – Base directory of DISDRODB. Format:
<...>/DISDRODB
. IfNone
(the default), thebase_dir
path specified in the DISDRODB active configuration will be used.
- Returns
List or tuple of values of the metadata key.
- Return type
list or tuple
- disdrodb.metadata.get_list_metadata(data_sources=None, campaign_names=None, station_names=None, with_stations_data=True, base_dir=None)[source]#
Get the list of metadata filepaths in the DISDRODB raw archive.
- Parameters
data_sources (str or list of str) – Name of data source(s) of interest. The name(s) must be UPPER CASE. The default is
None
.campaign_names (str or list of str) – Name of the campaign(s) of interest. The name(s) must be UPPER CASE. The default is
None
.station_names (str or list of str) – Station names of interest. The default is
None
.with_stations_data (bool) – If
True
, only return metadata filepaths that have corresponding data in the local DISDRODB raw archive. The default isTrue
.base_dir (str (optional)) – Base directory of DISDRODB. Format:
<...>/DISDRODB
. IfNone
(the default), thebase_dir
path specified in the DISDRODB active configuration will be used.
- Returns
metadata_filepaths – List of metadata YAML file paths
- Return type
list
- disdrodb.metadata.read_station_metadata(data_source, campaign_name, station_name, base_dir=None, product='RAW')[source]#
Open the station metadata YAML file into a dictionary.
- Parameters
data_source (str) – The name of the institution (for campaigns spanning multiple countries) or the name of the country (for campaigns or sensor networks within a single country). Must be provided in UPPER CASE.
campaign_name (str) – The name of the campaign. Must be provided in UPPER CASE.
station_name (str) – The name of the station.
base_dir (str, optional) – The base directory of DISDRODB, expected in the format
<...>/DISDRODB
. If not specified, the path specified in the DISDRODB active configuration will be used.product (str, optional) – The DISDRODB product in which to search for the metadata file. The default is
"RAW"
.
- Returns
metadata – The station metadata dictionary
- Return type
dictionary