Commit 80ecde22 authored by Javier Vegas-Regidor's avatar Javier Vegas-Regidor
Browse files

Added docs

parent 03da0796
......@@ -13,6 +13,7 @@ from earthdiagnostics.utils import Utils
class DataConvention(object):
"""Base class to manage filename conventions"""
def __init__(self, name, config):
self.config = config
......@@ -62,9 +63,58 @@ class DataConvention(object):
return filepath
def get_file_name(self, startdate, member, domain, var, cmor_var, frequency, chunk, year, date_str, grid, ):
"""
Get filename for a given configuration
Parameters
----------
startdate: str
member: int
domain: ModelingRealm
var: str
cmor_var: Variable
frequency: Frequency
chunk: int or None
year: int or None
date_str: str or None
grid: str or None
Returns
-------
str
Raises
------
NotImplementedError:
If not implemented by derived classes
"""
raise NotImplementedError
def get_cmor_folder_path(self, startdate, member, domain, var, frequency, grid, cmor_var):
"""
Get the folder path following current CMOR convention
Parameters
----------
startdate: str
member: int
domain: ModelingRealm
var: str
frequency: Frequency
grid: str
cmor_var: Variable
Returns
-------
str
Raises
------
NotImplementedError:
If not implemented by derived classes
"""
raise NotImplementedError
def get_startdate_path(self, startdate):
......@@ -78,6 +128,7 @@ class DataConvention(object):
Returns
-------
str
"""
return os.path.join(self.config.data_dir, self.config.experiment.expid, 'cmorfiles', self.config.cmor.activity,
self.config.experiment.institute, self.config.experiment.model,
......@@ -102,9 +153,35 @@ class DataConvention(object):
return self.config.experiment.experiment_name
def get_member_str(self, member):
"""
Transalate member number to member string
Parameters
----------
member: int
Returns
-------
str
Raises
------
NotImplementedError:
If not implemented by derived classes
"""
raise NotImplementedError
def create_links(self, startdate, member=None):
"""
Create links for a given startdate or member
Parameters
----------
startdate: str
member: int or None
"""
if member is not None:
member_str = self.get_member_str(member)
else:
......@@ -223,6 +300,7 @@ class DataConvention(object):
class Cmor2Convention(DataConvention):
"""Base class for CMOR2-based conventions"""
def get_scratch_masks(self, scratch_masks):
return scratch_masks
......@@ -290,6 +368,7 @@ class Cmor2Convention(DataConvention):
class SPECSConvention(Cmor2Convention):
"""Base class for CMOR2-based conventions"""
def get_startdate_path(self, startdate):
return os.path.join(self.config.data_dir, self.config.experiment.expid, 'cmorfiles',
......@@ -298,7 +377,15 @@ class SPECSConvention(Cmor2Convention):
class PrefaceConvention(Cmor2Convention):
"""
Class to manage Preface convention
Parameters
----------
name: str
config: Config
"""
def __init__(self, name, config):
super(PrefaceConvention, self).__init__(name, config)
self.time_separator = '_'
......@@ -310,7 +397,15 @@ class PrefaceConvention(Cmor2Convention):
class Cmor3Convention(DataConvention):
"""Class managing Primavera file conventions"""
"""
Base class for CMOR3-based conventions
Parameters
----------
name: str
config: Config
"""
def __init__(self, name, config):
super(Cmor3Convention, self).__init__(name, config)
self.lat_name = 'latitude'
......@@ -436,6 +531,7 @@ class PrimaveraConvention(Cmor3Convention):
class MeteoFranceConvention(DataConvention):
"""Class managing MeteoFrance file conventions"""
def get_file_name(self, startdate, member, domain, var, cmor_var, frequency, chunk, year, date_str, grid,):
if year is not None:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment