예제 #1
0
parser.add_argument("FILE", nargs='*')

options = parser.parse_args()
args = options.FILE

nc = NC(args[0], 'r')

x = nc.variables['x'][:]
y = nc.variables['y'][:]
z = nc.variables['z'][:]

# The enthalpy convert expects Kelvin
inunits = nc.variables['temp'].units
outunits = 'K'
try:
    temp = ppt.unit_converter(
        np.squeeze(nc.variables['temp'][:]), inunits, outunits)
except:
    temp = np.squeeze(nc.variables['temp'][:])
    print(
        "WARNING: I don't know the units of variable temp, and assume it is Kelvin")

enthalpy_true = np.squeeze(nc.variables['enthalpy'][:])
usurf = np.squeeze(nc.variables['usurf'][:])
topg = np.squeeze(nc.variables['topg'][:])

context = PISM.Context()
config = context.config
EC = PISM.EnthalpyConverter(config)

enthalpy = np.zeros_like(temp)
예제 #2
0
    except:
        print((
            "ERROR:  unknown or not-found variable '%s' in file %s ... ending ..."
            % (variable.var_name, obs_file)))
        exit(2)

    try:
        inunit = str(nc.variables[myvar].units)
    except:
        print((
            "ERROR:  units not found in variable '%s' in file %s ... ending ..."
            % (variable.var_name, obs_file)))
        exit(2)

    if outunit is not None:
        data = ppt.unit_converter(data, inunit, outunit)

    if variable.var_name in vars_dem:
        mask = data <= variable.vmin
        obs_values = np.ma.array(data, mask=mask)
    elif variable.var_name in vars_topo:
        obs_values = data
    else:
        try:
            fill = nc.variables[var]._FillValue
            mask = data == fill
        except:
            mask = np.zeros_like(data)
            mask[data <= tol] = 1
        if tol:
            mask[data <= tol] = 1
예제 #3
0
    try:
        data = np.squeeze(ppt.permute(nc.variables[myvar], dim_order))
    except:
        print(("ERROR:  unknown or not-found variable '%s' in file %s ... ending ..."
               % (variable.var_name, obs_file)))
        exit(2)

    try:
        inunit = str(nc.variables[var].units)
    except:
        print(("ERROR:  units not found in variable '%s' in file %s ... ending ..."
               % (variable.var_name, obs_file)))
        exit(2)

    if outunit is not None:
        data = ppt.unit_converter(data, inunit, outunit)

    if variable.var_name in vars_dem:
        mask = (data <= variable.vmin)
        obs_values = np.ma.array(data, mask=mask)
    elif variable.var_name in vars_topo:
        obs_values = data
    else:
        try:
            fill = nc.variables[var]._FillValue
            mask = (data == fill)
        except:
            mask = np.zeros_like(data)
            mask[data <= tol] = 1
        if tol:
            mask[data <= tol] = 1
예제 #4
0
                sys.exit(1)
            varname = in_varname
            for name in nc.variables:
                v = nc.variables[name]
                if getattr(v, "standard_name", "") == in_varname:
                    print("variabe {0} found by its standard_name {1}".format(name,
                                                                              in_varname))
                    varname = name
            
            profile_axis = nc.variables['profile'][profile_id]
            profile_axis_units = nc.variables['profile'].units
            profile_axis_name = nc.variables['profile'].long_name

            profile_axis_out_units = 'km'
            profile_axis = np.squeeze(
                ppt.unit_converter(profile_axis[:], profile_axis_units, profile_axis_out_units))
            x = profile_axis

            my_var = nc.variables[varname]
            my_var_units = my_var.units
            my_var_p = ppt.permute(my_var, output_order=output_order)
            xdim, ydim, zdim, tdim = ppt.get_dims(nc)

            if tdim:
                data = np.squeeze(my_var_p[profile_id, 0, Ellipsis])
            else:
                data = np.squeeze(my_var_p[profile_id, Ellipsis])                
            data = ppt.unit_converter(data, my_var_units, o_units)

            if label_params[0] == 'none':
                exp_str = None