2. Modules

So far only one module.

2.1. noboinout

Module ‘nobotouls.inout’ defines routines for managing and plotting raw nobo station measurement files with help of a sqlite database and matplotlib routines.

noboinout.addtime2yymoddhhmi(idate, days=0, hours=0, minutes=0, seconds=0)[source]

Add time to a integer datetime

noboinout.all_nobo_raw_files(nobo_raw_dir='./', pattern='*.txt')[source]

Returns a list of raw nobo files for processing.

  • nobo_raw_dir … directory of nobo raw files
  • pattern … file pattern for globbing (e.g. ‘nobo*.csv’ …)
  • returns a list of matching file names
noboinout.convert_datadict_value(value)[source]

Converts the string variables that stand for numbers to floats

noboinout.create_aichfeld_db(dbfile)[source]

Creates an aichfeld-project general data file in ‘dbfile’. Returns a message string with success info.

noboinout.create_nobo_table(dbfile)[source]

Creates an aichfeld-project general data file in ‘dbfile’. Returns a message string with success info.

A more reasonable named alias for ‘create_aichfeld_db’)

noboinout.create_rain_table(nobodb)[source]

Create a noborain table in nobo-sqlite3-db

noboinout.create_station_table(nobodb)[source]

Create a empty nobo station table in nobo-sqlite3-db

noboinout.ddff2uv(dd, ff)[source]

Wind in met. direction dd and speed ff in x- and y-component u,v

noboinout.deg2dms(deg)[source]

Converts decimal degress to deg, minutes, seconds

noboinout.deletefiles(globpattern)[source]

Deletes files without request

noboinout.dms2deg(d, m, s)[source]

Converts deg, minutes, seconfs to decimal degrees

noboinout.fine_mpl_dattims(coarse_mpltimes, mpldattimdelta)[source]

Make of a coarse irregular grided matplotlib time array an regular array so that the lower and upper limits of the coarse array fits completely into the new equally spaced fine array.

noboinout.get_all_nobostation_infos(dbfile, onlyactive=False)[source]

Returns a dictionary of dictionares in the form stadict{‘stat’}{‘longname’,’lon’, ‘lat’, ‘elev’, ‘active’}

noboinout.get_all_nobostation_names(dbfile, onlyactive=False)[source]

Returns a list of all active stations. Set onlyactive to true, and only the active stations are returned.

noboinout.get_nobostation_info(dbfile, station)[source]

Get station info from db-table nobostations

noboinout.insert_aichfeld_rain_db(dbfile, raindata, replace=False)[source]

Insert new records in db rain table and ignores new ones in case of conflict.

  • dbfile … path to nobo database file
  • raindata … raindata of one station in a dictionary defined by noborain2timedeltarain.
  • returns True, otherwise it crashed.
noboinout.insert_ignore_aichfeld_db(dbfile, data)[source]

Insert new records in db and ignores new ones in case of conflict.

  • dbfile … path to nobo database file
  • data … data of one station in a dictionary defined by read_nobo_file.
  • returns True, otherwise it crashes.
noboinout.insert_replace_aichfeld_db(dbfile, data)[source]

Insert new records in db and replace old ones by new ones in case of conflict.

  • dbfile … path to nobo database file
  • data … data of one station in a dictionary defined by read_nobo_file.
  • returns True, otherwise it crashes.
noboinout.interpolate_mpldattim_floats(coarse_mpltimes, mpldattimdelta, coarse_floats)[source]

Interpolate a irregular and coarse time series to a fine grided array.

  • coarse_mpltimes .. coarse times array in matplotlib.date-objects
  • mpldattimdelta … time delta (to construct fine date-time array)
  • coarse_flotas … coarse floats

(the first time element of coarse_mpltimes is rounded down to integer times mpldattimdelta, the last time element is rounded up to inter times mpldattimdelta)

Returns:

  • fine matplotlib dattims (floats)
  • fine float array
noboinout.make_mercator_map_and_pickle(minlon, maxlon, minlat, maxlat, picklefile, resolution='f')[source]

Creates a pickle of am basemap object

noboinout.make_mercator_map_and_pickle_dm(minlon, maxlon, minlat, maxlat, picklefile, dempath=None, resolution='c')[source]

Creates a picklefile with a basemap object and a topo file with DM-data

noboinout.makepicklefilename(pickledir, coordinateedges)[source]

Construct a picklefilename dependent on coordinateedges

noboinout.moviemaker(picdir='./', moviefile='movie')[source]

Makes movies of png-pictures with mencoder

  • picpath … directory and basename of pictures to be expanded
    *.png”
  • moviefile … pathname of the movie-file to be expanded with “.avi”
noboinout.noborainsums(rawraindict)[source]

Construct and fill a dictionary with dattims and rainsums of a raw rain nobo dictionary.

rawraindict … dictionary with raw nobo rain data as read from csv
with read_nobo_rain_file

returns:

rainsumdata … dict. with arrays ‘dattims’ and ‘sum’

noboinout.plot_noborain(station, data, istartdattim=190001010000, ienddattim=210012311159, outfiledir='./', outfiletype='png', forced_outfile_name=None, dpi=75, rr_lim=(0.0, 30.0))[source]

Plots a rain-meteogramm of a single nobo station.

Inut-params:

  • station … station name (string)
  • istartdattim … start date-time as integer yyyymoddhhmi
  • ienddattim … end date-time as integer yyyymoddhhmi
  • outfiledir … directory where outputfile is to be written
  • outputfiletype … ‘png’, ‘pdf’, ‘jpg’ or whatever is allowed by matplotlib (defaults to png)
  • foreced_outfile_name … optional complete path of output image file
  • dpi … dots per inch (defaults to 75)
  • Tuples for limiting y-axes: * rr_lim … (tmin, tmax) for temp. C

Output:

  • Image-Outputfile either with name either of input parameter ‘forced_outfile_name’ or calculated in program ‘outfiledir + station + startdate + enddate + outfiletype’
noboinout.plot_raw_nobo(station, data, istartdattim=190001010000, ienddattim=210012311159, outfiledir='./', outfiletype='png', forced_outfile_name=None, dpi=75, tl_lim=(-5.0, 35.0), ps_lim=(925.0, 975.0), rh_lim=(0.0, 100.0), ff_lim=(0.0, 25.0), dd_lim=(0.0, 360.0))[source]

Plots a meteogramm of a single nobo station.

Inut-params:

  • station … station name (string)
  • istartdattim … start date-time as integer yyyymoddhhmi
  • ienddattim … end date-time as integer yyyymoddhhmi
  • outfiledir … directory where outputfile is to be written
  • outputfiletype … ‘png’, ‘pdf’, ‘jpg’ or whatever is allowed by matplotlib (defaults to png)
  • foreced_outfile_name … optional complete path of output image file
  • dpi … dots per inch (defaults to 75)
  • Tuples for limiting y-axes: * tl_lim … (tmin, tmax) for temp. C * ps_lim … (pmin, pmax) for press. hPa * rh_lim … (rhmin, rhmax) for rel. humidity % * ff_lim … (ffmin, ffmax) for wind speed (m/s) * dd_lim … (ddmin, ddmax) for wind direction (degree)

Output:

  • Image-Outputfile either with name either of input parameter ‘forced_outfile_name’ or calculated in program ‘outfiledir + station + startdate + enddate + outfiletype’
noboinout.plot_single_param(stationlist, dbfile='./resources/aichfeld_db.sqlite', istartdattim=190001010000, ienddattim=210012311159, parameter='ps', param_lim=(920.0, 960.0), outfiledir='./', outfiletype='png', forced_outfile_name=None, dpi=75)[source]

Plots a graph of a single nobo station with a single parameter.

Inut-params:

  • stationlist … list with station names (string), max 16!
  • istartdattim … start date-time as integer yyyymoddhhmi
  • ienddattim … end date-time as integer yyyymoddhhmi
  • parameter … ‘tl’, ‘rh’, ‘ps’, ‘dd’, ‘ff’, ‘fx’to plot
  • param_lim … (param_min, param_max) for parameter
  • outfiledir … directory where outputfile is to be written
  • outputfiletype … ‘png’, ‘pdf’, ‘jpg’ or whatever is allowed by matplotlib (defaults to png)
  • foreced_outfile_name … optional complete path of output image file
  • dpi … dots per inch (defaults to 75)

Output:

  • Image-Outputfile with name either of input parameter ‘forced_outfile_name’ or calculated in program ‘outfiledir + station + startdate + enddate + outfiletype’
noboinout.plot_wind(bmap, lon, lat, u=0, v=0, barbcolor='k', flagcolor='k', length=7, latlon=False, label='wind', fill_empty=False, emptybarb=0.05, nildata=False, station='')[source]

Plot a single wind barb with u,v in map ‘bmap’ at lat, lon

noboinout.prepare_map_with_dm(dempath, basem, regridsize=50.0)[source]

Plotting routin for wind chart: Prepare a windmap with high-res DM-data

noboinout.pydatetime2yymoddhhmi(dattim, fmt='%Y%m%d%H%M')[source]

Converts a single python datetime object to an integer date-time in the for yyyymoddhhmi, e.g. 201505241200 or to an integer identified by fmt (ATTENTION!)

noboinout.pydatetime_array(datetime1, datetime2, d_days=0, d_hours=0, d_minutes=0.0, d_seconds=0.0)[source]

Constructs an array/a list of python datetime objects with an increment of d_days,d_hours,d_minutes and d_seconds (all in integer, s_seconds in float)

noboinout.read_inputparms(parmfile)[source]

Read input parameters from an user interface file for nobotouls

noboinout.read_nobo_file(input_csv)[source]

Reads single nobo-station file from Aichfeld project and returns a numpy array for futher processing.

  • input_csv … raw nobo input file (more or less US-csv format

Reurns (with redundancies):

  • station … short nobo station name
  • headers … header line with original long nobo field names
  • data … a dictionary with short internal field names indicating arrays with field variables, eg. data[‘tl’]: * ‘stat’ … nobo station name * ‘dattim’ … date and times as integer datetime in UTC(!) * ‘timez’ … timezone read from nobo file (LMT = UTC + timez) * ‘dattiml’… date amd time for local time zone in integer * ‘tl’ … air temperatur C * ‘rh’ … relative humidity % * ‘ps’ … station pressure hPa * ‘ff’ … 10 min mean wind speed m/s * ‘fx’ … 10 min max wind speed m/s (gusts) * ‘dd’ … wind direction degrees 0..360
noboinout.read_noborain_file(input_csv)[source]

Reads single nobo-rain-station file from Aichfeld project and returns a numpy array for futher processing.

  • input_csv … raw nobo input file (more or less US-csv format

Reurns (with redundancies):

  • station … short nobo station name
  • headers … header line with original long nobo field names
  • data … a dictionary with short internal field names indicating arrays with field variables, eg. data[‘tl’]: * ‘stat’ … nobo station name * ‘dattim’ … date and times as integer datetime in UTC(!) * ‘timez’ … timezone read from nobo file (LMT = UTC + timez) * ‘dattiml’… date amd time for local time zone in integer * ‘event’ … rain event of 0.1 mm * ‘coupldisconn’ … coupler disconnected * ‘couplconn’ … coupler connected * ‘hostconn’ … host connected * ‘eofile’ … end of file
noboinout.retrieve_aichfeld_db(dbfile, station, istartdatetime, ienddatetime)[source]

Retreives nobo station data from sqlite database table noborw.

Input-params:

  • dbfile … sqlite-database file
  • istatdatetime … in integer for (yyymoddhhmi)
  • istartendtime … in integer for (yyymoddhhmi)

Returns:

  • data … dictionary with all db-fields data[‘stat’], … * ‘stat’, ‘dattim’, ‘dattiml’, ‘..’timez’, etc ..
noboinout.retrieve_aichfeld_raindb(dbfile, station, istartdatetime, ienddatetime)[source]

Retreives nobo station rain data from sqlite database table noborain.

Input-params:

  • dbfile … sqlite-database file
  • istatdatetime … in integer for (yyymoddhhmi)
  • istartendtime … in integer for (yyymoddhhmi)

Returns:

  • data … dictionary with all db-fields data[‘stat’], … * ‘stat’, ‘dattim’, ‘dattiml’, ‘tiemz’, ‘rr’, ‘obs’
noboinout.retrieve_single_datum(dbfile, station, itime)[source]

Retrieve a single data set for one station and time from database. If empty the value ‘None’ is returned.

noboinout.scan_nobo_header(head)[source]

Scans the data record header for fieldnames and determines its order

noboinout.scan_nobo_timezone(timehead, seconds=False)[source]

Get timezone as an timedelta-object from nobo-file header. Return as timdedelta object and as integer hhmm, if seconds = True, then hhmmss. Defaults to False

noboinout.scan_noborain_header(head)[source]

Scans the data record header for fieldnames and determines its order

noboinout.show_dict(dictio, header='')[source]

Displays the vontent of the dictionary ‘dict’ with an optional header line ‘header’.

noboinout.signum(x)[source]

Missing signum-function in python math lib

noboinout.time2ceil(mptime, mptimedelta)[source]

Take the next lower time of mptime that is an (alomst) integer multiple of mptimedelta

noboinout.time2floor(mptime, mptimedelta)[source]

Take the next lower time of mptime that is an (alomst) integer multiple of mptimedelta

noboinout.windplot(dbfile, picklefilename, outdirname, startdatetime, enddatetime, delta=10, maptitle='', convert=1.94384449)[source]

Main plotting routine for wind chart

noboinout.windplot_dm(dbfile, picklefilename, outdirname, startdatetime, enddatetime, delta=10, maptitle='', convert=1.94384449, dempath=None)[source]

Main plotting routine for wind chart

noboinout.yymoddhhmi2pydatetime(idattim, fmt='%Y%m%d%H%M')[source]

Converts a single integer-date-times, e.g. 201505241200, to a python datetime object.

Probably unnecessarily complicated, but just to avoid side effects for earlier calls … sigh …