Newer
Older
"""Contains the enumeration-like classes used by the diagnostics"""
:param name: full basin's name
:type name: str
def __init__(self, name):
self._name = name
def __eq__(self, other):
return False
return True
def __ne__(self, other):
return not self == other
def __gt__(self, other):
return self.name > other.name
def __lt__(self, other):
return self.name < other.name
def __ge__(self, other):
return self.name >= other.name
def __le__(self, other):
return self.name <= other.name
Javier Vegas-Regidor
committed
def __repr__(self):
return str(self)
def __hash__(self):
return hash(str(self))
"""Singleton class to manage available basins"""
def __new__(cls, *args, **kwargs):
if cls.__instance is None:
cls.__instance = object.__new__(cls, *args, **kwargs)
cls.__instance.__initialize()
return cls.__instance
def __initialize(self):
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
'Atlantic_Ocean': ('atl', 'atlantic'),
'North_Atlantic_Ocean': ('natl', 'north_atlantic'),
'Tropical_Atlantic_Ocean': ('tatl', 'tropical_atlantic'),
'Pacific_Ocean': ('pac', 'pacific'),
'North_Pacific_Ocean': ('npac', 'north_pacific'),
'Tropical_Pacific_Ocean': ('tpac', 'tropical_pacific'),
'Indo_Pacific_Ocean': ('indpac', 'indo_pacific'),
'Indian_Ocean': ('ind', 'indian'),
'Tropical_Indian_Ocean': ('tind', 'tropical_indian'),
'Antarctic_Ocean': ('anta', 'antarctiv'),
'Antarctic_Atlantic_Sector': ('antaatl', 'antarctic_atlantic'),
'Antarctic_Indian_Sector': ('antaind', 'antarctic_indian'),
'Arctic_Ocean': ('arct', 'arctic'),
'Arctic_Ocean_North_Atlantic': ('arctnatl', 'artic_north_atlantic'),
'Arctic_Marginal_Seas': ('arctmarg', 'arctic_marginal'),
'Baffin': ('Baffin',),
'Baffin_Bay': ('BaffBay',),
'Baltic_Sea': ('Baltic',),
'BarKara': ('BarKara',),
'Barents_Sea': ('Barents',),
'Beaufort_Chukchi_Sea': ('BeaufortChukchi',),
'Beaufort_Sea': ('Beaufort',),
'Bellingshausen_Sea': ('Bellingshausen',),
'Bering': ('Bering',),
'Bering_Strait': ('BeringStr',),
'CanArch': ('CanArch',),
'Canadian_Waters': ('Canadian',),
'Caspian_Sea': ('Caspian',),
'Central_Arctic': ('CArct',),
'Chukchi_Sea': ('Chukchi',),
'East_Siberian_Sea': ('ESiberian',),
'Eastern_Central_Arctic': ('ECArct',),
'Fram_Strait': ('Fram',),
'Greenland_Sea': ('Greenland',),
'Grnland': ('Grnland',),
'Hudson': ('Hudson',),
'Icelandic_Sea': ('Iceland',),
'Irminger_Sea': ('Irminger',),
'Kara_Gate_Strait': ('KaraGate',),
'Kara_Sea': ('Kara',),
'Labrador_Sea': ('Labrador',),
'Laptev_East_Siberian_Chukchi_Seas': ('LaptevESiberianChukchi',),
'Laptev_East_Siberian_Seas': ('LaptevESiberian',),
'Laptev_Sea': ('Laptev',),
'Lincoln_Sea': ('Lincoln',),
'Mediterranean_Sea': ('Medit',),
'Nares_Strait': ('Nares',),
'Nordic_Barents_Seas': ('NordicBarents',),
'Nordic_Seas': ('Nordic',),
'NorthWest_Passage': ('NWPass',),
'North_Atlantic-Arctic': ('North_Atlantic-Arctic',),
'North_Hemisphere_Ocean': ('NHem',),
'Norwegian_Sea': ('Norwegian',),
'Okhotsk': ('Okhotsk',),
'OpenOcean': ('OpenOcean',),
'Ross_Sea': ('Ross',),
'Serreze_Arctic': ('SerArc',),
'Southern_Hemisphere': ('SHem',),
'StLawr': ('StLawr',),
'Subpolar_Gyre': ('Subpolar_Gyre',),
'TotalArc': ('TotalArc',),
'Vilkitsky_Strait': ('Vilkitsky_Strait',),
'Weddell_Sea': ('Weddell_Sea',),
'Western_Central_Arctic': ('Western_Central_Arctic',),
}
self.Global = Basin('Global')
self.Atlantic = Basin('Atlantic_Ocean')
self.Pacific = Basin('Pacific_Ocean')
self.IndoPacific = Basin('Indo_Pacific_Ocean')
self.Indian = Basin('Indian_Ocean')
self._add_alias('glob', self.Global)
for basin in (self.Global, self.Atlantic, self.Pacific, self.IndoPacific, self.Indian):
for alias in self.aliases[basin.name]:
self._add_alias(alias, basin)
self.__initiated = False
:param handler:
:type handler: netCDF4.Dataset
setattr(self, basin, basin_object)
self._add_alias(basin, basin_object)
for alias in self.aliases[basin]:
self._add_alias(alias, basin_object)
Javier Vegas-Regidor
committed
def _add_alias(self, basin, basin_object):
self._known_aliases[basin.lower()] = basin_object
Javier Vegas-Regidor
committed
If the parameter basin is a Basin instance, directly returns the same
instance. This bahaviour is intended to facilitate the development of
methods that can either accept a nameor a Basin instance to characterize the basin.
:param basin: basin name or basin instance
:type basin: str | Basin
:return: basin instance corresponding to the basin name
:rtype: Basin
"""
if isinstance(basin, Basin):
return basin
return self._known_aliases[basin]
ECEARTH_2_3_O1L42 = 'Ec2.3_O1L42'
""" EC-Earth 2.3 ORCA1 L42"""
ECEARTH_3_0_O1L46 = 'Ec3.0_O1L46'
""" EC-Earth 3 ORCA1 L46 """
ECEARTH_3_0_O25L46 = 'Ec3.0_O25L46'
""" EC-Earth 3 ORCA0.25 L46 """
ECEARTH_3_0_O25L75 = 'Ec3.0_O25L75'
""" EC-Earth 3 ORCA0.25 L75 """
ECEARTH_3_1_O25L75 = 'Ec3.1_O25L75'
""" EC-Earth 3.1 ORCA0.25 L75 """
ECEARTH_3_2_O1L75 = 'Ec3.2_O1L75'
""" EC-Earth 3.2 ORCA1 L75 """
ECEARTH_3_2_O25L75 = 'Ec3.2_O25L75'
""" EC-Earth 3.2 ORCA0.25 L75 """
NEMO_3_2_O1L42 = 'N3.2_O1L42'
""" NEMO 3.2 ORCA1 L42 """
NEMO_3_3_O1L46 = 'N3.3_O1L46'
""" NEMO 3.3 ORCA1 L46 """
NEMO_3_6_O1L46 = 'N3.6_O1L75'
""" NEMO 3.6 ORCA1 L75 """
NEMOVAR_O1L42 = 'nemovar_O1L42'
""" NEMOVAR ORCA1 L42 """
GLORYS2_V1_O25L75 = 'glorys2v1_O25L75'
""" GLORYS2v1 ORCA0.25 L75 """