API reference

Here are the main functions of SCAHpy:

in_out.read_wrf_multi

in_out.read_wrf_multi(files,list_no_vars,difHor=0,sign=1)

Read a list of wrfout files for the variables selected.

Parameters:

  • files : List of wrfout files
  • list_no_vars : List of variables to be delated
  • difHor : String with the hours t
  • sign: -1 or 1 according to the difference

Returns

  • fig (matplotlib.figure.Figure)
  • ax (matplotlib.axes.Axes)

in_out.read_wrf_single

in_out.ds_wrf_single(file,list_no_vars,difHor=0,sign=1)

Read a list of wrfout files for the variables selected.

Parameters:

  • file : List of wrfout files
  • list_no_vars : List of variables to be delated
  • difHor : String with the hours t
  • sign: -1 or 1 according to the difference

Returns

  • fig (matplotlib.figure.Figure)
  • ax (matplotlib.axes.Axes)

in_out.extract_station_wrf

in_out.extract_station_wrf(out,station,lon_col, lat_col, name_col, output_format='netcdf')

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

met_diag.calc_pp(ds, elim=False)

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

met_diag.calc_wsp(ds, elim=False)

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

met_diag.calc_pres(ds, elim=False)

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

met_diag.calc_tp(ds, elim=False)

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

met_diag.calc_qe(ds, elim=False)

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

spatial_scales.vert_levs(ds,varis,lvls=None):

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

temp_scales.dmy_var(ds,tiempo=None ,accum=None, avg=None, mediana=None):

Convert hourly (default wrf out) time to any acceptable by resample function.

Parameters:

  • ds : Dataset loaded
  • tiempo : Time accepted by resample
  • accum : List of variables who need sum
  • avg : if True use the mean function
  • mediana : if True use the median function

Returns

  • netcdf xarray.Dataset

temp_scales.monthly_clim

temp_scales.monthly_clim(ds, stat=None, time_slice=None):

Convert a Dataset to monthly climatology.

Parameters:

  • ds : Dataset loaded
  • stat : Mean or median
  • time_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 loaded
  • var : str with the variable’s name

Returns

  • netcdf xarray.Dataset