Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NWIS Daily Values Records Not Downloading for Newer Sites #2

Open
mhaserodt16 opened this issue Oct 22, 2019 · 0 comments
Open

NWIS Daily Values Records Not Downloading for Newer Sites #2

mhaserodt16 opened this issue Oct 22, 2019 · 0 comments

Comments

@mhaserodt16
Copy link

mhaserodt16 commented Oct 22, 2019

Seems like the URL for the DV sites has changed. I noticed that data for newer sites does not download with the old URL construction. The sites pull into the field sites table fine with the old url and it seems like misc measurements are coming in but the daily values are not. I updated the make_dv_url function to this and this seems to work.

def make_dv_url(self, station_IDs, parameter_code='00060', start_date='1880-01-01', end_date=None):
    """Creates url to retrieve daily values for a site


    Parameters
    ----------
    stationIDs: int, str or list of ints or strings
        USGS station IDs

    parameter_code: (string)
        e.g. 00060 for discharge.
        See http://help.waterdata.usgs.gov/codes-and-parameters/parameters.

    start_date: (string) 'YYYY-DD-MM'
        To obtain the entire period-of-record use a start date of 1880-01-01 (default)...

    Notes
    -----
    A leading zero is added to the site number if the first digit is greater than 1
    (this can happend for basins 01 - 09 if the site number gets converted to an int).
    Note that this may cause site numbers for basin 01 (North Atlantic slope) to get confused with
    basins 10-16 (west coast and hawaii).
    See <http://help.waterdata.usgs.gov/faq/sites/do-station-numbers-have-any-particular-meaning>

    """

    if not isinstance(station_IDs, list):
        station_IDs = [str(station_IDs)]

    def add_leading_zero(station_ID):
        if 1 < int(str(station_ID)[0]) < 10:
            station_ID = '0{}'.format(station_IDs)
        return station_ID

    #station_IDs = ','.join(['0{}'.format(int(str(s))) for s in station_IDs])
    station_IDs = ','.join([self._correct_stationID(s) for s in station_IDs])

    url = 'https://waterdata.usgs.gov/nwis/dv?cb_00060=on&format=rdb'
	
    url += '&site_no={}'.format(station_IDs)
    url += '&begin_date={}'.format(start_date)
    if end_date is not None:
        url += '&end_date={}'.format(end_date)
    #url += '&parameterCd={}'.format(parameter_code)
    print('{}'.format(url))
    return url
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant