gnssrefl.download_noaa module

gnssrefl.download_noaa.download_noaa(station: str, date1: str, date2: str, output: str = None, plt: bool = False, datum: str = 'mllw', subdir: str = None)

Downloads NOAA tide gauge files and stores locally If you ask for 31 days of data or less, it will download exactly what you ask for. But if you want a longer time series, this code needs to query the NOAA API every month. To make the code easier to write, I start with the first day of the first month you ask for and end with last day in the last month.

Output is written to REFL_CODE/Files/ unless subdir optional input is set Plot is sent to the screen if requested.

Parameters:
  • station (str) – 7 character ID of the station.

  • date1 (str) – start date. Example value: 20150101

  • date2 (str) – end date. Example value: 20150110

  • output (string, optional) – Optional output filename default is None

  • plt (boolean, optional) – plot comes to the screen default is None

  • datum (string, optional) – set to lwd for lakes? default is mllw

  • subdir (str, optional) – subdirectory for output in the $REFL_CODE/Files area

gnssrefl.download_noaa.download_qld(station, year, plt)
Parameters:
  • station (str) – tide gauge station name

  • year (int) – calendar year

  • plt (bool) – whether you want a plot to the screen

gnssrefl.download_noaa.multimonthdownload(station, datum, fout, year1, year2, month1, month2, csv)

downloads NOAA water level measurements > one month

Parameters:
  • station (str) – NOAA station name

  • datum (str) – definition of water level datum

  • results (fout - fileID for writing) –

  • year1 (int) – year when first measurements will be downloaded

  • month1 (integer) – month when first measurements will be downloaded

  • year2 (integer) – last year when measurements will be downloaded

  • month2 (integer) – last month when measurements will be downloaded

  • csv (boolean) – whether output file is csv format

Returns:

  • tt (list of times) – modified julian day

  • obstimes (list of datetime objects)

  • slevel (list or is it numpy ??) – water level in meters

gnssrefl.download_noaa.noaa2me(date1)

converts NOAA type of date string to simple integers

Parameters:

date1 (string) – time in format YYYYMMDD for year month and day

Returns:

  • year1 (integer) – full year

  • month1 (integer) – month

  • day1 (integer) – day of the month

  • doy (integer) – day of year

  • modjulday (float) – modified julian date

gnssrefl.download_noaa.noaa_command(station, fout, year, month1, month2, datum, metadata, tt, obstimes, slevel, csv)

downloads/writes NOAA tidegauge data for one month

Parameters:
  • station (str) – station name

  • year (int) – full year

  • month1 (int) – starting month

  • month2 (int) – ending month

  • datum (str) – water datum

  • metadata (bool) – whether you want the metadata printed to the screen

  • tt (numpy array) – modified julian date for water measurements

  • obstimes (numpy array of datetimes) – time of the measurements

  • slevel (numpy array of floats) – water level in meters

  • csv (bool) – True if csv output wanted (default is False)

Returns:

  • tt (numpy array) – modified julian date for water measurements

  • obstimes (numpy array) – datetime format, updated with new data

  • slevel (numpy array) – sea level (m) updated with new data

gnssrefl.download_noaa.pickup_from_noaa(station, date1, date2, datum, printmeta)

pickup up NOAA data between date1 and date2, which can be longer than one month (NOAA API restriction)

Parameters:
  • station (str) – station name

  • date1 (str) – beginning time, 20120101 is January 1, 2012

  • date2 (str) – end time , same format

  • datum (str) – what kind of datum is requested

  • printmeta (bool) – print metadata to screen

Returns:

  • data (dictionary in NOAA format)

  • error (bool)

gnssrefl.download_noaa.write_out_data(data, fout, tt, obstimes, slevel, csv)

writes out the NOAA water level data to a file 20213-mar-27 using new format

Parameters:
  • data (dictionary from NOAA API) –

  • fout (file ID) – for output

  • tt

  • obstimes (list of datetimes) – times of water level measurements

  • slevel (numpy array of floats) – water level in meters

  • csv (boolean) – whether csv format or not

Returns:

  • tt (same as input, but larger)

  • obstimes (list of datetimes) – times for waterlevels

  • slevel (list of floats) – water levels in meters