This script gives easy access to USHCN monthly raw, TOBS and Final adjusted temperatures.
Getting the data:
wget ftp://ftp.ncdc.noaa.gov/pub/data/ushcn/v2.5/ushcn.tavg.latest.FLs.52j.tar.gz
wget ftp://ftp.ncdc.noaa.gov/pub/data/ushcn/v2.5/ushcn.tavg.latest.tob.tar.gz
wget ftp://ftp.ncdc.noaa.gov/pub/data/ushcn/v2.5/ushcn.tavg.latest.raw.tar.gz
tar xzvf ushcn.tavg.latest.FLs.52j.tar.gz
tar xzvf ushcn.tavg.latest.tob.tar.gz
tar xzvf ushcn.tavg.latest.raw.tar.gz
wget ftp://ftp.ncdc.noaa.gov/pub/data/ushcn/v2.5/ushcn.tmax.latest.FLs.52j.tar.gz
wget ftp://ftp.ncdc.noaa.gov/pub/data/ushcn/v2.5/ushcn.tmax.latest.tob.tar.gz
wget ftp://ftp.ncdc.noaa.gov/pub/data/ushcn/v2.5/ushcn.tmax.latest.raw.tar.gz
wget http://cdiac.ornl.gov/ftp/ushcn_daily/ushcn-stations.txt
tar xzvf ushcn.tmax.latest.FLs.52j.tar.gz
tar xzvf ushcn.tmax.latest.tob.tar.gz
tar xzvf ushcn.tmax.latest.raw.tar.gz
wget ftp://ftp.ncdc.noaa.gov/pub/data/ushcn/v2.5/ushcn.tmin.latest.FLs.52j.tar.gz
wget ftp://ftp.ncdc.noaa.gov/pub/data/ushcn/v2.5/ushcn.tmin.latest.tob.tar.gz
wget ftp://ftp.ncdc.noaa.gov/pub/data/ushcn/v2.5/ushcn.tmin.latest.raw.tar.gz
tar xzvf ushcn.tmin.latest.FLs.52j.tar.gz
tar xzvf ushcn.tmin.latest.tob.tar.gz
tar xzvf ushcn.tmin.latest.raw.tar.gz
Then cd into the new directory, which will have a new name every day. It will be something like ushcn.v2.5.5.20191004
Example usage:
python3 date.py USH00412679 7 1921 “EAGLE PASS”
Data for July, 1921 at Eagle Pass, Texas.
output:
Raw EAGLE PASS USH00412679 7 1921 37.29 99.12
TOBS EAGLE PASS USH00412679 7 1921 37.16 98.89
Final EAGLE PASS USH00412679 7 1921 35.92 96.66
Last two numbers in each line are Degrees C and Degrees F
You will have to know the station ID of the station you are looking for:
ftp://ftp.ncdc.noaa.gov/pub/data/ushcn/v2.5/ushcn-v2.5-stations.txt
Script :
——————————————————————-
import sys filename = sys.argv[1] #print(filename) #filename = filename.replace("USC", "USH") #print(filename) month = int(sys.argv[2]) year = sys.argv[3] comment = sys.argv[4] fd = open(filename + ".raw.tmax") for line in fd : #print(line[12:16]) if (line[12:16] == year) : #print(line) offset = 18 + (9 * (month - 1)) #print(line[offset:offset+4]) temperature_c = float(line[offset:offset+4]) / 100.0 temperature_f = (temperature_c * 1.8) + 32.0 print("Raw", comment, filename, month, year, "%.2f" % temperature_c, "%.2f" % temperature_f) fd = open(filename + ".tob.tmax") for line in fd : #print(line[12:16]) if (line[12:16] == year) : #print(line) offset = 18 + (9 * (month - 1)) #print(line[offset:offset+4]) temperature_c = float(line[offset:offset+4]) / 100.0 temperature_f = (temperature_c * 1.8) + 32.0 print("TOBS", comment, filename, month, year, "%.2f" % temperature_c, "%.2f" % temperature_f) fd = open(filename + ".FLs.52j.tmax") for line in fd : #print(line[12:16]) if (line[12:16] == year) : #print(line) offset = 18 + (9 * (month - 1)) #print(line[offset:offset+4]) temperature_c = float(line[offset:offset+4]) / 100.0 temperature_f = (temperature_c * 1.8) + 32.0 print("Final", comment, filename, month, year, "%.2f" % temperature_c, "%.2f" % temperature_f)