'value': 1200, 'units': 'W m^-2' }}) model_time_step = timedelta(seconds=600) # Create components convection = climt.EmanuelConvection() simple_physics = TimeDifferencingWrapper(climt.SimplePhysics()) constant_duration = 6 radiation_lw = UpdateFrequencyWrapper(climt.RRTMGLongwave(), constant_duration * model_time_step) radiation_sw = UpdateFrequencyWrapper(climt.RRTMGShortwave(), constant_duration * model_time_step) slab_surface = climt.SlabSurface() insolation = climt.Instellation() dycore = climt.GFSDynamicalCore( [simple_physics, slab_surface, radiation_sw, radiation_lw, 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
'stellar_irradiance': {'value': 200, 'units': 'W m^-2'}}) model_time_step = timedelta(seconds=600) # Create components convection = climt.EmanuelConvection() simple_physics = TimeDifferencingWrapper(climt.SimplePhysics()) constant_duration = 6 radiation_lw = UpdateFrequencyWrapper( climt.RRTMGLongwave(), constant_duration*model_time_step) radiation_sw = UpdateFrequencyWrapper( climt.RRTMGShortwave(), constant_duration*model_time_step) slab_surface = climt.SlabSurface() dycore = climt.GFSDynamicalCore( [simple_physics, slab_surface, radiation_sw, radiation_lw, convection], number_of_damped_levels=5 ) grid = climt.get_grid(nx=NUM_COLS, ny=NUM_ROWS) # 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
convection = climt.EmanuelConvection( convective_momentum_transfer_coefficient=1) simple_physics = climt.SimplePhysics() simple_physics = simple_physics.prognostic_version() simple_physics.current_time_step = model_time_step convection.current_time_step = model_time_step # run radiation once every hour constant_duration = 3 radiation_lw = climt.RRTMGLongwave() radiation_lw = radiation_lw.piecewise_constant_version(constant_duration * model_time_step) radiation_sw = climt.RRTMGShortwave(use_solar_constant_from_fortran=False) radiation_sw = radiation_sw.piecewise_constant_version(constant_duration * model_time_step) slab_surface = climt.SlabSurface() # Create model state my_state = climt.get_default_state( [ dycore, radiation_lw, radiation_sw, convection, simple_physics, slab_surface ], x=dycore.grid_definition['x'], y=dycore.grid_definition['y'], mid_levels=dycore.grid_definition['mid_levels'], interface_levels=dycore.grid_definition['interface_levels'])
def init_radiative_state(self, atmosphere, surface): climt.set_constants_from_dict({ "stellar_irradiance": { "value": self.solar_constant, "units": 'W m^-2' } }) if self._is_mcica: overlap = 'maximum_random' else: overlap = 'random' self._rad_lw = climt.RRTMGLongwave( cloud_optical_properties=self._cloud_optical_properties, cloud_ice_properties=self._cloud_ice_properties, cloud_liquid_water_properties='radius_dependent_absorption', cloud_overlap_method=overlap, mcica=self._is_mcica) self._rad_sw = climt.RRTMGShortwave( ignore_day_of_year=True, cloud_optical_properties=self._cloud_optical_properties, cloud_ice_properties=self._cloud_ice_properties, cloud_liquid_water_properties='radius_dependent_absorption', cloud_overlap_method=overlap, mcica=self._is_mcica) state_lw = {} state_sw = {} plev = atmosphere['plev'] phlev = atmosphere['phlev'] numlevels = len(plev) for state0 in state_lw, state_sw: state0['mid_levels'] = DataArray(np.arange(0, numlevels), dims=('mid_levels', ), attrs={'label': 'mid_levels'}) state0['interface_levels'] = DataArray( np.arange(0, numlevels + 1), dims=('interface_levels', ), attrs={'label': 'interface_levels'}) state0['air_pressure'] = DataArray(plev, dims=('mid_levels', ), attrs={'units': 'Pa'}) state0['air_pressure_on_interface_levels'] = DataArray( phlev, dims=('interface_levels', ), attrs={'units': 'Pa'}) state0['time'] = datetime.datetime(2000, 1, 1) ### Aerosols ### # TODO: Should all the aerosol values be zero?! # Longwave specific num_lw_bands = self._rad_lw.num_longwave_bands state_lw['longwave_optical_thickness_due_to_aerosol'] = DataArray( np.zeros((num_lw_bands, numlevels)), dims=('num_longwave_bands', 'mid_levels'), attrs={'units': 'dimensionless'}) state_lw['surface_longwave_emissivity'] = DataArray( surface.longwave_emissivity * np.ones((num_lw_bands, )), dims=('num_longwave_bands'), attrs={'units': 'dimensionless'}) # Shortwave specific changes num_sw_bands = self._rad_sw.num_shortwave_bands num_aerosols = self._rad_sw.num_ecmwf_aerosols state_sw['aerosol_optical_depth_at_55_micron'] = DataArray( np.zeros((num_aerosols, numlevels)), dims=('num_ecmwf_aerosols', 'mid_levels'), attrs={'units': 'dimensionless'}) state_sw['solar_cycle_fraction'] = DataArray( 0, attrs={'units': 'dimensionless'}) state_sw['flux_adjustment_for_earth_sun_distance'] = DataArray( 1, attrs={'units': 'dimensionless'}) for surface_albedo in [ 'surface_albedo_for_diffuse_near_infrared', 'surface_albedo_for_direct_near_infrared', 'surface_albedo_for_diffuse_shortwave', 'surface_albedo_for_direct_shortwave' ]: state_sw[surface_albedo] = DataArray( np.array(float(surface.albedo)), attrs={'units': 'dimensionless'}) for quant in [ 'shortwave_optical_thickness_due_to_aerosol', 'single_scattering_albedo_due_to_aerosol', 'aerosol_asymmetry_parameter' ]: state_sw[quant] = DataArray(np.zeros((num_sw_bands, numlevels)), dims=('num_shortwave_bands', 'mid_levels'), attrs={'units': 'dimensionless'}) return state_lw, state_sw
#!/usr/bin/env python2 # -*- coding: utf-8 -*- """ Created on Tue Nov 14 22:44:38 2017 @author: zifan """ import climt import matplotlib.pyplot as plt import numpy as np from sympl import AdamsBashforth from datetime import timedelta incoming_radiation = climt.RRTMGShortwave( cloud_overlap_method=0, solar_constant = 2500) outgoing_radiation = climt.RRTMGLongwave( cloud_overlap_method=0) convection = climt.EmanuelConvection() surface = climt.SlabSurface() state = climt.get_default_state([incoming_radiation, outgoing_radiation, convection]) model_time_step = timedelta(hours=24) model = AdamsBashforth([incoming_radiation, outgoing_radiation, convection]) for step in range(50): diagnostics, new_state = model(state, model_time_step)
def get_component_instance(self): return climt.RRTMGShortwave(mcica=True)
def init_radiative_state(self, atmosphere, surface): climt.set_constants_from_dict({ "stellar_irradiance": { "value": self.solar_constant, "units": "W m^-2" } }) if self._is_mcica: overlap = "maximum_random" else: overlap = "random" self._rad_lw = climt.RRTMGLongwave( cloud_optical_properties=self._cloud_optical_properties, cloud_ice_properties=self._cloud_ice_properties, cloud_liquid_water_properties="radius_dependent_absorption", cloud_overlap_method=overlap, mcica=self._is_mcica, ) self._rad_sw = climt.RRTMGShortwave( ignore_day_of_year=True, cloud_optical_properties=self._cloud_optical_properties, cloud_ice_properties=self._cloud_ice_properties, cloud_liquid_water_properties="radius_dependent_absorption", cloud_overlap_method=overlap, mcica=self._is_mcica, ) state_lw = {} state_sw = {} plev = atmosphere["plev"] phlev = atmosphere["phlev"] numlevels = len(plev) for state0 in state_lw, state_sw: state0["mid_levels"] = DataArray( np.arange(0, numlevels), dims=("mid_levels", ), attrs={"label": "mid_levels"}, ) state0["interface_levels"] = DataArray( np.arange(0, numlevels + 1), dims=("interface_levels", ), attrs={"label": "interface_levels"}, ) state0["air_pressure"] = DataArray(plev, dims=("mid_levels", ), attrs={"units": "Pa"}) state0["air_pressure_on_interface_levels"] = DataArray( phlev, dims=("interface_levels", ), attrs={"units": "Pa"}) state0["time"] = datetime.datetime(2000, 1, 1) ### Aerosols ### # TODO: Should all the aerosol values be zero?! # Longwave specific num_lw_bands = self._rad_lw.num_longwave_bands state_lw["longwave_optical_thickness_due_to_aerosol"] = DataArray( np.zeros((num_lw_bands, numlevels)), dims=("num_longwave_bands", "mid_levels"), attrs={"units": "dimensionless"}, ) state_lw["surface_longwave_emissivity"] = DataArray( surface.longwave_emissivity * np.ones((num_lw_bands, )), dims=("num_longwave_bands"), attrs={"units": "dimensionless"}, ) # Shortwave specific changes num_sw_bands = self._rad_sw.num_shortwave_bands num_aerosols = self._rad_sw.num_ecmwf_aerosols state_sw["aerosol_optical_depth_at_55_micron"] = DataArray( np.zeros((num_aerosols, numlevels)), dims=("num_ecmwf_aerosols", "mid_levels"), attrs={"units": "dimensionless"}, ) state_sw["solar_cycle_fraction"] = DataArray( 0, attrs={"units": "dimensionless"}) state_sw["flux_adjustment_for_earth_sun_distance"] = DataArray( 1, attrs={"units": "dimensionless"}) for surface_albedo in [ "surface_albedo_for_diffuse_near_infrared", "surface_albedo_for_direct_near_infrared", "surface_albedo_for_diffuse_shortwave", "surface_albedo_for_direct_shortwave", ]: state_sw[surface_albedo] = DataArray( np.array(float(surface.albedo)), attrs={"units": "dimensionless"}) for quant in [ "shortwave_optical_thickness_due_to_aerosol", "single_scattering_albedo_due_to_aerosol", "aerosol_asymmetry_parameter", ]: state_sw[quant] = DataArray( np.zeros((num_sw_bands, numlevels)), dims=("num_shortwave_bands", "mid_levels"), attrs={"units": "dimensionless"}, ) return state_lw, state_sw