Example #1
0
def create_output_file():
    records = {
        'ID': 'DWR_Zarate',
        'Name': 'Zárate',
        'Source': 'C3S_SouthAmerica',
        'Lat': '-34.0958',
        'Lon': -59.0242,
        'Link': 'https://data-rescue.copernicus-climate.eu/lso/1086267',
        'Vbl': 'mslp',
        'Stat': 'point',
        'Units': 'Pa',
        'Meta': 'Data policy=GNU GPL v3.0',
        'Year': [1902, 1902],
        'Month': [9, 9],
        'Day': [2, 3],
        'Hour': [11, 11],
        'Minute': [17, 17],
        'Value': [102245, 101952],
        'Period': [0, 0],
        'Meta2': ['Orig=766.9mm|Orig.time=', 'Orig.=764.7mm|Orig.time='],
        'offset': -4
    }

    obs = SEF.create(records)

    SEF.write_file(obs, OUTPUT_PATH)
    'DWR_Estc_Pereyra', 'DWR_Puerto_Mili.'
]

# Date to show
year = 1902
month = 8
day = 27
hour = 18
minute = 0  # obs are at 18:17 UTC, but show the field at 18:00
dte = datetime.datetime(year, month, day, hour, minute)

# Load all the Argentine DWR pressures at this time
adf = glob.glob('../../../../sef/Argentinian_DWR/1902/DWR_*_MSLP.tsv')
obs = {'Name': [], 'Latitude': [], 'Longitude': [], 'mslp': []}
for file in adf:
    stobs = SEF.read_file(file)
    df = stobs['Data']
    hhmm = int("%2d%02d" % (dte.hour, 17))
    mslp = df.loc[(df['Year'] == dte.year) & (df['Month'] == dte.month) &
                  (df['Day'] == dte.day) & (df['HHMM'] == hhmm)]
    if mslp.empty: continue
    if mslp['Value'].values[0] == mslp['Value'].values[0]:
        obs['Name'].append(stobs['ID'])
        obs['Latitude'].append(stobs['Lat'])
        obs['Longitude'].append(stobs['Lon'])
        obs['mslp'].append(mslp['Value'].values[0])
obs = pandas.DataFrame(obs)

# Landscape page
aspect = 16 / 9.0
fig = Figure(
Example #3
0
                    type=str,required=True)
args = parser.parse_args()

pickled_20CRdata_dir="%s/sef_comparators/Argentinian_DWR/" % os.getenv('SCRATCH')

# Load the obs
known_bad=False
obs_file="../../../../sef/Argentinian_DWR/1902/%s_T.tsv" % args.id
obs_Tmax_file="../../../../sef/Argentinian_DWR/1902/%s_Tmax.tsv" % args.id
obs_Tmin_file="../../../../sef/Argentinian_DWR/1902/%s_Tmin.tsv" % args.id
if not os.path.isfile(obs_file):
    known_bad=True
    obs_file="../../../../sef/Argentinian_DWR/known_bad/1902/%s_T.tsv" % args.id
    obs_Tmax_file="../../../../sef/Argentinian_DWR/known_bad/1902/%s_Tmax.tsv" % args.id
    obs_Tmin_file="../../../../sef/Argentinian_DWR/known_bad/1902/%s_Tmin.tsv" % args.id
obs=SEF.read_file(obs_file)
obs_Tmax=SEF.read_file(obs_Tmax_file)
obs_Tmin=SEF.read_file(obs_Tmin_file)

# load the pickled 20CR data
rdata={}
rmax=0.0
rmin=1000000.0
start_day=datetime.datetime(1902, 2, 1, 0)
end_day  =datetime.datetime(1902,12,31, 0)
current_day=start_day
while current_day<=end_day:
    for hour in (0,3,6,9,12,15,18,21):
        pfile="%s/%04d/%02d/%02d/%02d/%s_air.2m.pkl" % (pickled_20CRdata_dir,
                                                       current_day.year,
                                                       current_day.month,
Example #4
0
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("--id", help="Station to compare",
                    type=str,required=True)
args = parser.parse_args()

known_bad=False
obs_file="../../../../sef/Argentinian_DWR/1902/%s_MSLP.tsv" % args.id
if not os.path.isfile(obs_file):
    known_bad=True
    obs_file="../../../../sef/Argentinian_DWR/known_bad/1902/%s_MSLP.tsv" % args.id

pickled_20CRdata_dir="%s/sef_comparators/Argentinian_DWR/" % os.getenv('SCRATCH')

# Load the obs
obs=SEF.read_file(obs_file)

# load the pickled 20CR data
rdata={}
rmax=0.0
rmin=1000000.0
start_day=datetime.datetime(1902, 2, 1, 0)
end_day  =datetime.datetime(1902,12,31, 0)
current_day=start_day
while current_day<=end_day:
    for hour in (0,3,6,9,12,15,18,21):
        pfile="%s/%04d/%02d/%02d/%02d/%s_prmsl.pkl" % (pickled_20CRdata_dir,
                                                       current_day.year,
                                                       current_day.month,
                                                       current_day.day,
                                                       hour,args.id)
Example #5
0
# Get the DWR data for 1902
obs = DWR.load_observations('prmsl', datetime.datetime(1903, 1, 1, 0),
                            datetime.datetime(1903, 12, 31, 23))
# Where to put the output files
opdir = "%s/../../../sef/UK_DWR/1903" % bindir
if not os.path.isdir(opdir):
    os.makedirs(opdir)

stations = list(set(obs['name']))
for station in stations:
    obs_s = obs[obs['name'] == station]
    ob_hhmm = [
        "%2d%02d" % (obs_s['hour'].values[i], obs_s['minute'].values[i])
        for i in range(len(obs_s))
    ]
    sef = SEF.create(version='0.0.1')
    sef['ID'] = station
    sef['Name'] = DWR.pretty_name(station)
    sef['Lat'] = obs['latitude'].values[0]
    sef['Lon'] = obs['longitude'].values[0]
    sef['Alt'] = None
    sef['Source'] = None
    sef['Repo'] = None
    sef['Var'] = 'msl pressure'
    sef['Units'] = 'hPa'
    sef['Meta'] = 'PTC=T,PGC=T'
    sef['Data'] = pandas.DataFrame({
        'Year': obs_s['year'].values,
        'Month': obs_s['month'].values,
        'Day': obs_s['day'].values,
        'HHMM': ob_hhmm,
Example #6
0
    station_height = station_locations[station_locations['SEF_ID'] ==
                                       args.id]['height'].values[0]
except IndexError:
    raise Exception("Missing original name for %s" % args.id)
spreadsheet_file = "%s/../raw_data/1903/DATA_1903_%s.csv" % (bindir,
                                                             original_name)
if not os.path.isfile(spreadsheet_file):
    raise Exception("Missing file %s" % spreadsheet_file)
raw_data = pandas.read_csv(spreadsheet_file, header=1)
n_values = len(raw_data)

# Make a SEF data structure and populate the common elements
# Argentine national time in 1903 was 4h17m behind UTC
#ob_time=[1117 if raw_data['MONTH'].values[i]>8 else 1817 for i in range(n_values)]
ob_time = 1117
common = SEF.create(version='0.0.1')
common['ID'] = args.id
common['Name'] = original_name
common['Lat'] = station_lat
common['Lon'] = station_lon
common['Alt'] = station_height
common['Source'] = None
common['Repo'] = None
common['Data'] = pandas.DataFrame({
    'Year': raw_data['YEAR'].values,
    'Month': raw_data['MONTH'].values,
    'Day': raw_data['DAY'].values,
    'HHMM': ob_time
})

# Where to put the output files