def try1(): radiation = climt.GrayLongwaveRadiation() surface = climt.SlabSurface() state = climt.get_default_state([radiation, surface]) tendencies, diagnostics = radiation(state) print tendencies.keys() print print tendencies['air_temperature']
def __init__(self, dt_seconds=1800, nx=64, ny=32, nz=10, state=None, input_fields_to_store=input_vars, output_fields_to_store=output_vars, input_save_fn=None, output_save_fn=None, save_interval=6, convection=None, extra_components=[]): """ Initialize model. Uses SSTs from Andersen and Kuang 2012. Creates initial state unless state is given. """ climt.set_constants_from_dict( {'stellar_irradiance': { 'value': 200, 'units': 'W m^-2' }}) self.model_time_step = timedelta(seconds=dt_seconds) self.step_counter = 0 self.save_interval = save_interval # Create components if convection is None: convection = climt.EmanuelConvection( tendencies_in_diagnostics=True) simple_physics = TimeDifferencingWrapper( climt.SimplePhysics(tendencies_in_diagnostics=True)) radiation = climt.GrayLongwaveRadiation(tendencies_in_diagnostics=True) components = [simple_physics, radiation, convection] + extra_components self.dycore = climt.GFSDynamicalCore(components, number_of_damped_levels=2) grid = climt.get_grid(nx=nx, ny=ny, nz=nz) if state is None: self.create_initial_state(grid) else: self.state = state if not input_save_fn is None: self.input_netcdf_monitor = NetCDFMonitor( input_save_fn, write_on_store=True, store_names=input_fields_to_store) if not output_save_fn is None: self.output_netcdf_monitor = NetCDFMonitor( output_save_fn, write_on_store=True, store_names=output_fields_to_store)
def try2(): radiation = climt.GrayLongwaveRadiation() condensation = climt.GridScaleCondensation() x = dict(label='some_x_coord', values=np.linspace(0, 20, 10), dims='some_x_coord', units='kilometer') y = dict(label='some_y_coord', values=np.linspace(0, 20, 10), dims='some_y_coord', units='degrees_north') state = climt.get_default_state([radiation], x=x, y=y) print state['air_temperature'] state['air_temperature'].plot() plt.show() print radiation.tendencies print radiation.diagnostics print condensation.outputs print condensation.diagnostics
# Create plotting object monitor = PlotFunctionMonitor(plot_function) climt.set_constants_from_dict( {'stellar_irradiance': { 'value': 200, 'units': 'W m^-2' }}) model_time_step = timedelta(seconds=600) # Create components convection = climt.EmanuelConvection() simple_physics = TimeDifferencingWrapper(climt.SimplePhysics()) radiation = climt.GrayLongwaveRadiation() dycore = climt.GFSDynamicalCore([simple_physics, radiation, convection], number_of_damped_levels=5) grid = climt.get_grid(nx=128, ny=62) # Create model state my_state = climt.get_default_state([dycore], grid_state=grid) # Set initial/boundary conditions latitudes = my_state['latitude'].values longitudes = my_state['longitude'].values surface_shape = [len(longitudes), len(latitudes)] # Set initial/boundary conditions