def find_xml_fx(name, project='', experiment='', realm=''):
    list_obs = ReferenceObservations().keys()
    if name in list_obs:
        file_area = join_path(xmldir,
                              'obs_' + str(name) + '_glob_fx_O_areacell.xml')
        file_land = join_path(xmldir,
                              'obs_' + str(name) + '_glob_fx_O_landmask.xml')
    else:
        file_area = join_path(
            xmldir,
            str(name) + '_' + str(project) + '_' + str(experiment) +
            '_r0i0p0_glob_fx_' + str(realm) + '_areacell.xml')
        file_land = join_path(
            xmldir,
            str(name) + '_' + str(project) + '_' + str(experiment) +
            '_r0i0p0_glob_fx_' + str(realm) + '_landmask.xml')
    try:
        xml = CDMS2open(file_area)
    except:
        file_area = None
    try:
        xml = CDMS2open(file_land)
    except:
        file_land = None
    return file_area, file_land
def find_xml(name,
             frequency,
             variable,
             project='',
             experiment='',
             ensemble='',
             realm=''):
    list_obs = ReferenceObservations().keys()
    if name in list_obs:
        file_name, file_area, file_land = find_xml_obs(name, frequency,
                                                       variable)
    else:
        file_name, file_area, file_land = find_xml_cmip(
            name, project, experiment, ensemble, frequency, realm, variable)
    return file_name, file_area, file_land
Ejemplo n.º 3
0
def find_xml_fx(name, project='', experiment='', realm=''):
    list_obs = ReferenceObservations().keys()
    if name in list_obs:
        file_area = OSpath__join(xmldir, 'obs_' + str(name) + '_areacell.xml')
        file_land = OSpath__join(xmldir, 'obs_' + str(name) + '_landmask.xml')
    else:
        file_area = OSpath__join(
            xmldir,
            str(name) + '_' + str(project) + '_' + str(experiment) +
            '_r0i0p0_glob_fx_' + str(realm) + '_areacell.xml')
        file_land = OSpath__join(
            xmldir,
            str(name) + '_' + str(project) + '_' + str(experiment) +
            '_r0i0p0_glob_fx_' + str(realm) + '_landmask.xml')
    return file_area, file_land
Ejemplo n.º 4
0
# references
ref_colors = {'model': 'r', 'obs': 'k'}
ref_obs = {
    'ssh': 'AVISO',
    'pr': 'GPCPv2.3',
    'sst': 'HadISST',
    'lhf': 'Tropflux',
    'lwr': 'Tropflux',
    'shf': 'Tropflux',
    'swr': 'Tropflux',
    'taux': 'Tropflux',
    'thf': 'Tropflux'
}
# metric collections
list_MC = sorted(defCollection().keys(), key=lambda v: v.upper())
list_obs = sorted(ReferenceObservations().keys(), key=lambda v: v.upper())
# model
model = "CNRM-CM5"
# path
path_main = '/Users/yannplanton/Documents/Yann/Fac/2016_2018_postdoc_LOCEAN/2018_06_ENSO_metrics/2019_05_report/Data/v20190515'
path_plot = '/Users/yannplanton/Documents/Yann/Fac/2016_2018_postdoc_LOCEAN/2018_06_ENSO_metrics/2019_05_report/Wiki'
# ---------------------------------------------------#
# get arguments
try:
    SYSargv[1]
except:
    print '     no argument given'
    print ''
    metric_col = 'ENSO_perf'  # 'CM6_perf'
    experiment = 'historical'
else:
Ejemplo n.º 5
0
if mc_name == 'MC1':
    list_obs = ['Tropflux']
elif mc_name == 'ENSO_perf':
    list_obs = ['Tropflux','GPCPv2.3']
elif mc_name == 'ENSO_tel':
    list_obs = ['HadISST','GPCPv2.3']
print '\033[95m' + str(list_obs) + '\033[0m'


#
# finding file and variable name in file for each observations dataset
#
dict_obs = dict()
for obs in list_obs:
    # @jiwoo: be sure to add your datasets to EnsoCollectionsLib.ReferenceObservations if needed
    dict_var = ReferenceObservations(obs)['variable_name_in_file']
    dict_obs[obs] = dict()
    for var in list_variables:
        #
        # finding variable name in file
        #
        # @jiwoo: correct / adapt the 'varname' in
        # EnsoCollectionsLib.ReferenceObservations(obs)['variable_name_in_file'][var] if it is not correct or if you
        # changed a name in the xml
        # I usually alias the variable names from observations and models in the xml in order to have the same name
        # for sst (or any other variable) in every xml. This way I don not need to go through this function to know the
        # variable name in file
        try: var_in_file = dict_var[var]['var_name']
        except:
            print '\033[95m' + str(var) + " is not available for " + str(obs) + " or unscripted" + '\033[0m'
        else: