pyPSCF package

Submodules

pyPSCF.BackTrajHysplit module

class pyPSCF.BackTrajHysplit.BT(station=None, lat=None, lon=None, alt=None, dateMin=None, dateMax=None, stepHH=None, hBT=None, dirOutput=None, dirGDAS=None, dirHysplit=None, cpu=None)[source]

Bases: object

Compute the back-trajectory for the given station between dateMin and dateMax.

Parameters:
  • station (str) – The station
  • lat (float) – Latitude of the starting point
  • lon (float) – Longitude of the starting point
  • alt (float) – Altitude of the starting point
  • dateMin (str) – Starting date “YYYY-MM-DD HH:MM”
  • dateMax (str) – Ending date “YYYY-MM-DD HH:MM”
  • stepHH (int) – Interval between 2 starting hour
  • hBT (int (negative)) – Number of hour to go in the past
  • dirOutput (str) – path to the output directory
  • dirGDAS (str) – path to the GDAS meteorological directory
  • dirHysplit (str) – path to the hysplit root directory
  • cpu (int) – Number of CPU to use. Beware, each of them is use to its maximum.
compute_BT(date, filename)[source]

Compute the BT for the given datetime

Parameters:
  • date (datetime) – The datetime to compute
  • filename (str) – The name of the output file
compute_BTs()[source]

Compute all the BT from dateMin to dateMax

get_currentFile(station, d)[source]

Return the name of the file given a station and a date

Parameters:
  • station (str) – The name of the station
  • d (datetime) – The datetime of the backtrajectory
Returns:

currentFile – traj_{station}_{YYMMDDHH}

Return type:

str

run()[source]

Run compute_BTs one time per cpu each in a subprocess.

update_date(d, stepHH)[source]

Update the date by a given step

Parameters:
  • d (datetime) – Previous datetime
  • stepHH (int) – Number of hour to go forward
Returns:

datetime – d + stepHH

Return type:

datetime

write_CONTROL_file(curDate, currentFile)[source]

Create the correct CONTROL file for the given date

Parameters:
  • curDate (datetime) – The datetime to compute
  • currentFile (str) – The name of the file
write_SETUP_file()[source]

Well… write the setup file

pyPSCF.pyPSCF module

class pyPSCF.pyPSCF.PSCF(station, specie, lat0, lon0, folder, prefix, add_hour, concFile, dateMin, dateMax, percentile=75, threshold=None, wfunc=True, wfunc_type='auto', resQuality='110m', smoothplot=True, mapMinMax=None, cutWithRain=True, hourinthepast=72, plotBT=True, plotPolar=True, pd_kwarg=None)[source]

Bases: object

Parameters:
  • station (str) – The name of the station.
  • specie (str) – The specie to study. Must be specified in the concentration file.
  • lat0 (float) – The latitude of the starting point.
  • lon0 (float) – The longitude of the starting point.
  • folder (str, path) – Path to the backtrajectories files.
  • prefix (str) – Prefix of all backtrajectories. Something like ‘traj_OPE_’
  • add_hour (list or array) –

    List of backtrajecories starting hours around the reference hour. Example: add_hour=[-3,0,3] and reference hour of 2017-03-15 09:00, the following backtrajectories will be used:

    • 2017-03-15 06:00
    • 2017-03-15 09:00
    • 2017-03-15 12:00

    All theses backtrajecories are associated to the concentration of the refrence hour.

  • concFile (str, path.) – The path to the concentration file.
  • dateMin (str or datetime object) – The minimal date to account.
  • dateMax (str or datetime object) – The maximal date to account.
  • percentile (int, default 75) – The percentile to use as threshold.
  • threshold (float, default None) – The concentration threshold. It overrides the percentile value.
  • wfunc (boolean, default True) – Either or not use a weighting function.
  • wfunc_type ("manual" or "auto", default "auto") – Type of weighting function. “auto” is continuous.
  • mapMinMax (dict) – Dictionary of minimun/maximum of lat/lon for the map. Example: mapMinMax = {‘latmin’: 37.5, ‘latmax’: 60, ‘lonmin’: -10, ‘lonmax’: 20} This example is the default (France centered).
  • cutWithRain (boolean, default True) – Either or not cut the backtrajectory to the last rainning date.
  • hourinthepast (integer, default 72) – Number of hour considered for the backtrajectory life.
  • resQuality ('110m' or '50m', default '110m') – The quality of the map.
  • smoothplot (boolean, default True) – Use a gaussian filter to smooth the map plot.
  • plotBT (boolean, default True) – Either or not plot all the backtraj in a new axe.
  • plotPolar (boolean, default True) – Either or not plot the direction the distribution of the PSCF in a polar plot.
Other Parameters:
 

pd_kwarg (dict, optional) – Dictionary of option pass to pd.read_csv to read the concentration file. By default, pd_kwarg={‘index_col’=0, ‘parse_date’=[‘date’]}.

extractBackTraj()[source]

Sum up back trajectories file into a pandas DataFrame according to the class parameters.

Returns:df
Return type:pd.DataFrame
onclick(event, plotType)[source]

Find the BT which pass through the clicked cell.

plot_PSCF()[source]

Plot the PSCF map.

plot_PSCF_polar()[source]

Plot a polar plot of the PSCF

plot_backtraj()[source]

Plot a map of all trajectories.

run()[source]

Run the PSCF model and add 4 attributes to the PSCF object:

Returns:
  • ngrid_ (ndarray) – The number of end-point of back-trajectories in each grid cell
  • mgrid_ (ndarray) – The number of en-point of back-trajectories in each grid cell accociated with concentration > self.concCrit
  • PSCF_ (ndarray) – mgrid/ngrid, the PSCF data.
  • trajdensity_ (ndarray) – log_10(ngrid)
toRad(x)[source]

Module contents