GeoEco.DataProducts.NOAA.ClimateIndices.PSLClimateIndices.UrlToTable
- classmethod PSLClimateIndices.UrlToTable(url, database, table, field, dateDataType='datetime', intDataType='int32', floatDataType='float64', useNullForNoData=True, overwriteExisting=False)
Creates and populates a table of climate index values parsed from NOAA PSL climate index time series data downloaded from a URL.
Requires: Python requests module.
- Parameters:
url (
str) –URL to a text file containing climate index data in PSL time series format.
https://psl.noaa.gov/data/climateindices/list/ contains a large table that lists the available climate index data produced by PSL. The left column contains hyperlinks to the datasets and the right column contains the descriptions of the datasets. Find the dataset you are interested in, extract the URL from the hyperlink, and provide it to this tool.
For example, if you are interested in the Oceanic Niño Index (ONI), scroll down the table until you reach ONI in the left column. Click on the ONI hyperlink to bring up the page https://psl.noaa.gov/data/correlation/oni.data. Copy/paste that URL from your browser. Minimum length꞉ 1.
database (
Database) – Database that will receive the new table.table (
str) –Table to create and populate. The table will have four fields:
IndexDate(date) - the date of the first day of the month and year of the climate index value (e.g. 1-March-1960), in the database’s date data type.IndexYear(integer) - the year of the climate index value (e.g. 1990).IndexMonth(integer) - the month of the climate index value, ranging from 1 to 12.Value(float) - the climate index value for that month and year. The name of this field is specified by the field parameter, and need not beValue.
The second two fields store the same data as the first field but are present for your convenience, in case you prefer the year and month broken out as integers.
The rows will be inserted in ascending date order and all 12 months will be included for every year. If these months occur in the future they will be assigned the missing_value parsed from the input data, or NULL if useNullForNoData is True. Minimum length꞉ 1.
field (
str) – Name of the field to receive the climate index value. Minimum length꞉ 1.dateDataType (
str, optional) – Data type to use for theIndexDatefield. Allowed values꞉'datetime'. Case sensitive.intDataType (
str, optional) – Data type to use for theIndexYearandIndexMonthfields. Allowed values꞉'int16','uint16','int32','uint32','int64','uint64'. Case sensitive.floatDataType (
str, optional) – Data type to use for theValuefield. Allowed values꞉'float32','float64'. Case sensitive.useNullForNoData (
bool, optional) – If True, a database NULL will be used wherever the original data has a missing_value. If False, the table will contain the missing_value as it appears in the original data.overwriteExisting (
bool, optional) – If True, the output table will be overwritten, if it exists. If False, aValueErrorwill be raised if the output table exists.
- Returns:
str: The created table.
2.
float: The value that means “no data is available” in the returned table. If setNoDataValuesToNone is False, it will be the missing_value parsed from the input data. If True, it will beNone.3.
str: The comment parsed from the input data. If no comment was present, an empty string will be returned.- Return type:
tupleof 3 items