obs_assimilate.value = obs_assimilate.value * 100 # to Pa # 20CRv3 data prmsl = twcr.load('prmsl', dte, version='4.5.1') # Get the observations used in 20CRv3 obs_t = twcr.load_observations_fortime(dte, version='4.5.1') # Filter to those assimilated and near the UK obs_s = obs_t.loc[((obs_t['Latitude'] > 0) & (obs_t['Latitude'] < 90)) & ( (obs_t['Longitude'] > 240) | (obs_t['Longitude'] < 100))].copy() # Update mslp by assimilating Fort William ob. prmsl2 = DIYA.constrain_cube( prmsl, lambda dte: twcr.load('prmsl', dte, version='4.5.1'), obs=obs_assimilate, obs_error=100, random_state=RANDOM_SEED, model=sklearn.linear_model.LinearRegression(), lat_range=(20, 85), lon_range=(280, 60)) mg.observations.plot(ax_one, obs_s, radius=0.15) mg.observations.plot(ax_one, obs_assimilate, radius=0.15, facecolor='red', lat_label='latitude', lon_label='longitude') # For each ensemble member, make a contour plot mg.pressure.plot(ax_one,
numpy.array((fw_extent[0] * 100, fw_extent[1] * 100)).reshape(-1, 1)) ax_scp.plot(fw_extent, pre / 100, color='black', lw=3) ax_scp2 = fig.add_axes([0.55, 0.07, 0.43, 0.89]) # x-axis ax_scp2.set_xlim(fw_extent) ax_scp2.set_xlabel('original MSLP at Fort William (hPa)') # y-axis ax_scp2.set_ylim(sw_extent) ax_scp2.set_ylabel( 'MSLP at Stornoway after assimilating Fort William observation (hPa)') # Adjust the mslp by assimilating the FW ob ST_adjusted = DIYA.constrain_point(ens_ST.data, ens_FW.data.reshape(-1, 1), model=model, obs=fwi * 100) ax_scp2.plot((fwi, fwi), sw_extent, color='red', lw=3) ax_scp2.scatter( ens_FW.data / 100, ST_adjusted / 100, 500, # Point size 'blue', # Color marker='.', edgecolors='face', linewidths=0.0, alpha=1, zorder=5) # Output as png
# Month to show year = 1903 month = 10 dte = datetime.datetime(year, month, 1, 0) # Get the DWR observations within +- 15 hours obs = DWR.load_observations( 'prmsl', dte, dte + relativedelta(days=1) - relativedelta(minutes=1)) # sort them from north to south obs = obs.sort_values(by='latitude', ascending=True) # Get the list of stations - preserving order stations = list(collections.OrderedDict.fromkeys(obs.loc[:, 'name']).keys()) # Add quality control flags obs['plausible'] = DIYA.qc_plausible_range(obs, min=880, max=1060) obs['background'] = DIYA.qc_first_guess(obs, nsd=3, osd=1, version='2c') # Portrait page fig = Figure( figsize=(15, len(stations)), # Width, Height (inches) dpi=100, facecolor=(0.88, 0.88, 0.88, 1), edgecolor=None, linewidth=0.0, frameon=False, subplotpars=None, tight_layout=None) canvas = FigureCanvas(fig) font = { 'family': 'sans-serif',
obs = DWR.load_observations('prmsl', dte - datetime.timedelta(hours=0.1), dte + datetime.timedelta(hours=0.1)) # Throw out the ones already used in 20CRv3 obs = obs[~obs['name'].isin(['ABERDEEN', 'VALENCIA', 'JERSEY'])] obs_assimilate = obs # Use deep copy instead? # Convert to normalised value same as reanalysis obs_assimilate.value = obs_assimilate.value * 100 # Update mslp by assimilating all obs. prmsl2 = DIYA.constrain_cube( prmsl, lambda dte: twcr.load('prmsl', dte, version='4.5.1'), obs=obs_assimilate, obs_error=obs_error, random_state=RANDOM_SEED, model=model, lat_range=(20, 85), lon_range=(280, 60)) mg.observations.plot(ax_centre, obs_s, radius=0.15) mg.observations.plot(ax_centre, obs_assimilate, radius=0.15, facecolor='red', lat_label='latitude', lon_label='longitude') # PRMSL spaghetti plot mg.pressure.plot(ax_centre,
obs['dtm'].append(mslp['dtm'].values[0]) obs = pandas.DataFrame(obs) # Throw out the suspected duds obs = obs[~obs['name'].isin(skip_stations)] # Throw out the specified station if args.omit is not None: obs = obs[~obs['name'].isin([args.omit])] # Convert to normalised value same as reanalysis obs.value = obs.value * 100 # Update mslp by assimilating all obs. prmsl2 = DIYA.constrain_cube( prmsl, lambda dte: twcr.load('prmsl', dte, version='4.5.1'), obs=obs, obs_error=obs_error, random_state=RANDOM_SEED, model=model, lat_range=(-80, 10), lon_range=(250, 350)) dumpfile = "%s/%04d%02d%02d%02d.pkl" % (opdir, args.year, args.month, args.day, args.hour) if args.omit is not None: dumpfile = "%s/%04d%02d%02d%02d_%s.pkl" % (opdir, args.year, args.month, args.day, args.hour, args.omit) pickle.dump(prmsl2, open(dumpfile, "wb"))