def get_3d_input_state(self): state = climt.get_default_state([self.get_component_instance()], grid_state=get_grid(nx=32, ny=32, nz=28)) # state = super(TestGFSDycoreWithDcmipInitialConditions, self).get_3d_input_state() state.update( climt.DcmipInitialConditions(add_perturbation=True)(state)) return state
def test_scaling_diagnostic_output(): dcmip = climt.DcmipInitialConditions() dcmip = dcmip.scaled_version(diagnostic_scale_factors=dict( eastward_wind=0)) state = climt.get_default_state([dcmip]) diagnostics = dcmip(state) assert np.all(diagnostics['eastward_wind'].values == 0)
def get_3d_input_state(self): component = self.get_component_instance() state = climt.get_default_state( [component], x=component.grid_definition['x'], y=component.grid_definition['y'], mid_levels=component.grid_definition['mid_levels'], interface_levels=component.grid_definition['interface_levels']) dcmip = climt.DcmipInitialConditions() out = dcmip(state, add_perturbation=True) state.update(out) return state
import climt from sympl import PlotFunctionMonitor def plot_function(fig, state): ax = fig.add_subplot(1, 1, 1) state['surface_air_pressure'].transpose().plot.contourf(ax=ax, levels=16) monitor = PlotFunctionMonitor(plot_function) dycore = climt.GfsDynamicalCore(number_of_longitudes=198, number_of_latitudes=94, dry_pressure=1e5) dcmip = climt.DcmipInitialConditions() my_state = climt.get_default_state( [dycore], x=dycore.grid_definition['x'], y=dycore.grid_definition['y'], mid_levels=dycore.grid_definition['mid_levels'], interface_levels=dycore.grid_definition['interface_levels']) my_state['surface_air_pressure'].values[:] = 1e5 dycore(my_state) out = dcmip(my_state, add_perturbation=True) my_state.update(out)
def plot_function(fig, state): ax = fig.add_subplot(1, 1, 1) CS = ax.contourf(state['longitude'], state['latitude'], state['surface_air_pressure'].to_units('mbar')) plt.colorbar(CS) ax.set_title('Surface Pressure at: '+str(state['time'])) monitor = PlotFunctionMonitor(plot_function) set_constant('reference_air_pressure', value=1e5, units='Pa') dycore = climt.GFSDynamicalCore() dcmip = climt.DcmipInitialConditions(add_perturbation=True) grid = climt.get_grid(nx=128, ny=64, nz=20) my_state = climt.get_default_state([dycore], grid_state=grid) timestep = timedelta(minutes=10) out = dcmip(my_state) my_state.update(out) for i in range(1000): diag, output = dycore(my_state, timestep) monitor.store(my_state) my_state.update(output)