API reference
Here are the main functions of SCAHpy:
in_out.read_wrf_multi
=0,sign=1) in_out.read_wrf_multi(files,list_no_vars,difHor
Read a list of wrfout files for the variables selected.
Parameters:
files
: List of wrfout fileslist_no_vars
: List of variables to be delateddifHor
: String with the hours tsign
: -1 or 1 according to the difference
Returns
fig
(matplotlib.figure.Figure)ax
(matplotlib.axes.Axes)
in_out.read_wrf_single
file,list_no_vars,difHor=0,sign=1) in_out.ds_wrf_single(
Read a list of wrfout files for the variables selected.
Parameters:
file
: List of wrfout fileslist_no_vars
: List of variables to be delateddifHor
: String with the hours tsign
: -1 or 1 according to the difference
Returns
fig
(matplotlib.figure.Figure)ax
(matplotlib.axes.Axes)
in_out.extract_station_wrf
='netcdf') in_out.extract_station_wrf(out,station,lon_col, lat_col, name_col, output_format
Extracts data from a WRF output file using station coordinates provided in a CSV or shapefile.
Parameters:
out
(nc): the wrf outfile already laoded.station
(str): Path to the CSV or shapefile containing station coordinates.lon_col
(str): Name of the column containing longitude values.lat_col
(str): Name of the column containing latitude values.name_col
(str): Name of the column containing station names.output_format
(str, optional): Output format (‘netcdf’ or ‘dataframe’). Defaults to ‘netcdf’.
Returns
fig
(matplotlib.figure.Figure)ax
(matplotlib.axes.Axes)
met_vars.calc_pp
=False) met_diag.calc_pp(ds, elim
de-acumulate the rainfall and save it as PP.
Parameters:
ds
(nc): dataset with the variables RAINC, RAINNC and RAINSH already loaded.elim
(bool): False (default) keep the old and new variables, True keep only the new variable.
Returns
netcdf
xarray.Dataset
met_vars.calc_wsp
=False) met_diag.calc_wsp(ds, elim
calculate the wind speed.
Parameters:
ds
(nc): dataset with the variables U10 and V10 already loaded with coordinates already processed.elim
(bool): False (default) keep the old and new variables, True keep only the new variable.
Returns
netcdf
xarray.Dataset
met_vars.calc_pres
=False) met_diag.calc_pres(ds, elim
calculate the total atmospheric pressure and save it as Presion.
Parameters:
ds
(nc): dataset with the variables P, PB already loaded with coordinates already processed.elim
(bool): False (default) keep the old and new variables, True keep only the new variable.
Returns
netcdf
xarray.Dataset
met_vars.calc_tp
=False) met_diag.calc_tp(ds, elim
calculate the potential temperature and save it as TPo.
Parameters:
ds
(nc): dataset with the variable T already loaded with coordinates already processed.elim
(bool): False (default) keep the old and new variables, True keep only the new variable.
Returns
netcdf
xarray.Dataset
met_vars.calc_qe
=False) met_diag.calc_qe(ds, elim
calculate the specific humidity and save it as QE.
Parameters:
ds
(nc): dataset with the variable QVAPOR already loaded with coordinates already processed.elim
(bool): False (default) keep the old and new variables, True keep only the new variable.
Returns
netcdf
xarray.Dataset
spatial_scales.vert_levs
=None): spatial_scales.vert_levs(ds,varis,lvls
Interpolate vertical levels to a pressure variable
Parameters:
ds
(nc): dataset already loaded.varis
(list): list of vertical variables to interpolate.lvls
(list): list of levels to be interpolated, if none provided, it will use [1000,975,950,925,900,850,800,700,600,500,400,300,200] as default.
Returns
netcdf
xarray.Dataset
temp_scales.dmy_var
=None ,accum=None, avg=None, mediana=None): temp_scales.dmy_var(ds,tiempo
Convert hourly (default wrf out) time to any acceptable by resample function.
Parameters:
ds
: Dataset loadedtiempo
: Time accepted by resampleaccum
: List of variables who need sumavg
: if True use the mean functionmediana
: if True use the median function
Returns
netcdf
xarray.Dataset
temp_scales.monthly_clim
=None, time_slice=None): temp_scales.monthly_clim(ds, stat
Convert a Dataset to monthly climatology.
Parameters:
ds
: Dataset loadedstat
: Mean or mediantime_slice
: use the slice(ini,fin)
Returns
netcdf
xarray.Dataset
temp_scales.daily_clim
temp_scales.daily_clim(ds, var):
Generate daily climatology using moving window (mw) each 15 days.
Parameters:
ds
: Dataset loadedvar
: str with the variable’s name
Returns
netcdf
xarray.Dataset