#!/usr/bin/env python3
from salem import geogrid_simulator
import matplotlib.gridspec as gridspec
import matplotlib.pyplot as plt

# plot the wrf domains over a natural earth
namelist_path = 'demo_files/namelist.wps.demo'  # ensure no comments in namelist
g, maps = geogrid_simulator(namelist_path)

fig = plt.figure(1, figsize=(5, 5))
gs = gridspec.GridSpec(1, 1)
ax = fig.add_subplot(gs[0])
maps[0].set_rgb(natural_earth='lr')
maps[0].visualize()

gs.tight_layout(fig)
plt.savefig('demo_files/wrf_domains.png',
            dpi=700,
            alpha=True,
            bbox_inches='tight')
plt.show()
示例#2
0
import os
import salem
from glob import glob
import pandas as pd
import numpy as np
import wrf
import netCDF4 as nc
import matplotlib.pyplot as plt
import matplotlib.dates as mdates
import seaborn as sns
from IQR_plot import plot_day_clm

# load map settings from wps namelist
fig_map, ax_map = plt.subplots(1, 1)
fpath = '../wrf_input/London-3domains/namelist.wps-london-3'
g, maps = salem.geogrid_simulator(fpath)
maps[0].set_rgb(natural_earth='hr')
maps[0].visualize(ax=ax_map, title='Domains')

# export the figure
fig_map.set_size_inches(6, 6)
fig_map.savefig('fig/map.png')


# load WRF results
fl_WRF = sorted(glob('wrfout*'))
ds = salem.open_mf_wrf_dataset(fl_WRF)


dswrf = nc.Dataset(fl_WRF[0])
x_pos, y_pos = wrf.ll_to_xy(dswrf, latitude=[51.], longitude=[-0.1])
示例#3
0
import xarray as xr
import numpy as np
import salem
import matplotlib.pyplot as plt
from salem.utils import get_demo_file
from salem import open_wrf_dataset, get_demo_file
from salem import geogrid_simulator
import cartopy
from salem import mercator_grid, Map, open_xr_dataset

# fpath = get_demo_file('namelist_mercator.wps')
fpath = 'namelist2.wps'
with open(fpath, 'r') as f:  # this is just to show the file
    print(f.read())

g, maps = geogrid_simulator(fpath)
print(g)
print('ss')
print(maps[0])
maps[0].set_rgb(natural_earth='lr')
maps[0].visualize(title='Anidamiento Qollpana Marzo 2018', addcbar=False)
plt.savefig('QollpanaMarzo2018.png', dpi=300)

plt.show()
plt.close()
#ALBBCK
ds = open_xr_dataset(
    "/home/opti3040a/Documentos/WRF15-08-19/wrfout_d01_2018-03-05_00:00:00")
grid = mercator_grid(center_ll=(-60.0, -17.9), extent=(75e5, 75e5))
smap = Map(grid, nx=500)
# VAR_SSO
示例#4
0
#%%
from salem import geogrid_simulator
import matplotlib.pyplot as plt

if __name__ == '__main__':
    geo_path = '/home/zzhzhao/code/python/wrfchem_2/data2/namelist.wps'
    g, maps = geogrid_simulator(geo_path)
    maps[0].set_rgb(natural_earth='lr')  # add a background image
    maps[0].visualize(title='Domains 1')
    plt.savefig('/home/zzhzhao/code/python/wrfchem_2/fig/domain.jpg', dpi=300)
# %%