# # Testing functionality (meeting format requirements, etc.) of supplemental # atmospheric scenario data. # # General test setup: reading in raw data (including a basic atmosphere), # expanding (where necessary), regridding (incl. extracting), executing # standard pre-RT calc internal test method atmfields_checkedCalc. # # # This case is for Jupiter and specifically tests # # - electron densities (given: 2x3 1D cases) # - all cases from Jupiter.mean and Jupiter.oval (each with 3 density # levels) in 1D with p_grid from altitude grid (CASE A) and user defined # p_grid (CASE B) # - a single case expanded to 3D (assuming the other cases behave in the # same way) with p_grid from altitude grid # - magnetic field (given: single 3D case with 3 components) # - extracting 1D case from 3D with p_grid from altitude grid # - global 3D case with p_grid from altitude grid (also tested with B's own # z_field) # - wind (given: 2 1D cases with 1 component) # - both expanded to global 3D case with p_grid from altitude grid # # Jana Mendrok 2013-02-26 Arts2 { INCLUDE "general/general.arts" INCLUDE "general/agendas.arts" INCLUDE "general/planet_jupiter.arts" # 1-dimensional atmosphere AtmosphereSet1D # We have to set the absorption lookup table interpolation order, # since we are using wind fields. atmfields_checkedCalc will otherwise throw an error. IndexSet( abs_f_interp_order, 1 ) Tensor3Create( edensity_field ) GriddedField3Create( gf3tmp ) StringCreate( caseext ) StringCreate( casefull ) StringCreate( basename ) StringCreate( atmcase ) IndexCreate( ncases ) IndexCreate( interp_order ) IndexSet( interp_order, 1 ) # Array with base case names ArrayOfStringCreate( basecasearray ) ArrayOfStringSet( basecasearray, ["planets/Jupiter/MPS/Jupiter.mean/Jupiter.mean", "planets/Jupiter/MPS/Jupiter.oval/Jupiter.oval", "planets/Jupiter/Khurana/Khurana"] ) # Array with Ne case names ArrayOfStringCreate( necasearray ) ArrayOfStringSet( necasearray, [".Ne.high", ".Ne.low", ".Ne.med"] ) ### #this is the real stuff, partI: electron density # We have to repeat that, as we have multiple Ne fields given, but each atm case # can have only one (in contrast to vmr profiles, where we could test all # profiles in a single run). We use a forloop for this, which we define here and # execute later on. AgendaCreate( forloop_agenda_Ne ) AgendaSet( forloop_agenda_Ne ){ # construct case name Copy( atmcase, basename ) Extract( casefull, necasearray, forloop_index ) Append( atmcase, casefull ) Print( atmcase, 0 ) # readin in raw data ReadXML( gf3tmp, atmcase ) #this is 1D data and we're doing 1D. but we need to regrid the raw data to # the calculation grid(s). for supplemental atm data (Ne, B, winds) this # requires manual regridding (in contrast to basic atm data, where this is # handled by AtmFieldsCalc. # so, first: regrid to p_grid (as we are in 1D, we don't need latlon regridding) GriddedFieldPRegrid( gf3tmp, p_grid, gf3tmp, interp_order, 1 ) # eventually, extract the data Tensor from the regridded GriddedField FieldFromGriddedField( edensity_field, p_grid, lat_grid, lon_grid, gf3tmp ) atmfields_checkedCalc atmgeom_checkedCalc #WriteXML( "ascii", p_grid ) #WriteXML( "ascii", z_field ) #WriteXML( "ascii", t_field ) #WriteXMLIndexed( "ascii", forloop_index, edensity_field ) } ##### # Ne: CASE A ##### # set atmospheric scenario Extract( basename, basecasearray, 0 ) # we manually select a minumim set of basic atm data (main atm constituents) abs_speciesSet( species=["H2", "He"] ) # get atm scenario raw data AtmRawRead( t_field_raw, z_field_raw, vmr_field_raw, abs_species, basename ) ##### # A-1) p_grid initialized from given altitude grid ##### # we need to include negative altitudes! p_gridFromZRaw( p_grid, z_field_raw, 0 ) AtmFieldsCalc( vmr_zeropadding=1 ) Extract( z_surface, z_field, 0 ) # now looping over the Ne cases (reading, 1D regridding, checking) Copy( forloop_agenda, forloop_agenda_Ne ) nelemGet( ncases, necasearray ) IndexStepDown( ncases, ncases ) ForLoop( forloop_agenda, 0, ncases, 1 ) ##### # A-2) p_grid set to a user defined grid (surely requries interpolation to calc-grid(s)) ##### VectorNLogSpace( p_grid, 401, 920e3, 1e-3 ) AtmFieldsCalc( vmr_zeropadding=1 ) Extract( z_surface, z_field, 0 ) # repeating forloop with different p_grid nelemGet( ncases, necasearray ) IndexStepDown( ncases, ncases ) ForLoop( forloop_agenda, 0, ncases, 1 ) ##### # Ne: CASE B ##### #Now Ne from the second case folder. For the rest, we use the profiles (t, z, # vmr) from above. # set atmospheric scenario Extract( basename, basecasearray, 1 ) #Copy( casefull, basename ) #StringSet( caseext, ".t" ) #Append( casefull, caseext ) #ReadXML( t_field_raw, casefull ) #Copy( casefull, basename ) #StringSet( caseext, ".z" ) #Append( casefull, caseext ) #ReadXML( z_field_raw, casefull ) ##### # B-1) p_grid initialized from given altitude grid ##### # we need to include negative altitudes! p_gridFromZRaw( p_grid, z_field_raw, 0 ) AtmFieldsCalc( vmr_zeropadding=1 ) Extract( z_surface, z_field, 0 ) # repeating forloop with CASE B Ne scenario nelemGet( ncases, necasearray ) IndexStepDown( ncases, ncases ) ForLoop( forloop_agenda, 0, ncases, 1 ) ##### # Magfield ##### #We continue with magnetic field (B). This is given in 3D, but first we try a 1D # case, i.e. we will extract data for a given geographical location. # We have only one set of B-field data given, hence we don't need a forloop here. VectorSet( lat_true, [-12.] ) VectorSet( lon_true, [10.] ) # construct atmcase Extract( basename, basecasearray, 2 ) #now reading and regridding of each of the 3 B-field components separately Copy( atmcase, basename ) StringSet( caseext, ".B_u" ) Append( atmcase, caseext ) ReadXML( gf3tmp, atmcase ) # first: regrid to p_grid GriddedFieldPRegrid( gf3tmp, p_grid, gf3tmp, interp_order, 1 ) # second: regrid to lat/lon_grid GriddedFieldLatLonRegrid( gf3tmp, lat_true, lon_true, gf3tmp, interp_order ) # last, extract the data Tensor from the regridded GriddedField FieldFromGriddedField( mag_u_field, p_grid, lat_grid, lon_grid, gf3tmp ) Copy( atmcase, basename ) StringSet( caseext, ".B_v" ) Append( atmcase, caseext ) ReadXML( gf3tmp, atmcase ) # first: regrid to p_grid GriddedFieldPRegrid( gf3tmp, p_grid, gf3tmp, interp_order, 1 ) # second: regrid to lat/lon_grid GriddedFieldLatLonRegrid( gf3tmp, lat_true, lon_true, gf3tmp, interp_order ) # last, extract the data Tensor from the regridded GriddedField FieldFromGriddedField( mag_v_field, p_grid, lat_grid, lon_grid, gf3tmp ) Copy( atmcase, basename ) StringSet( caseext, ".B_w" ) Append( atmcase, caseext ) ReadXML( gf3tmp, atmcase ) # first: regrid to p_grid GriddedFieldPRegrid( gf3tmp, p_grid, gf3tmp, interp_order, 1 ) # second: regrid to lat/lon_grid GriddedFieldLatLonRegrid( gf3tmp, lat_true, lon_true, gf3tmp, interp_order ) # last, extract the data Tensor from the regridded GriddedField FieldFromGriddedField( mag_w_field, p_grid, lat_grid, lon_grid, gf3tmp ) atmfields_checkedCalc atmgeom_checkedCalc #WriteXML( "ascii", mag_u_field ) #WriteXML( "ascii", mag_v_field ) #WriteXML( "ascii", mag_w_field ) ##### # and now in 3D ##### # grid settings AtmosphereSet3D VectorLinSpace( lat_grid, -90, 90, 18 ) VectorLinSpace( lon_grid, -20, 340, 18 ) # blowing up basic atmosphere (and surface) AtmFieldsExpand1D Extract( z_surface, z_field, 0 ) # rereading (we need the GriddedField, which we didn't keep), blowing up, and # regridding Ne. but we take only one of them, and assume the others to behave # in the same way. Extract( atmcase, basecasearray, 1 ) Extract( casefull, necasearray, 2 ) Append( atmcase, casefull ) Print( atmcase, 0 ) ReadXML( gf3tmp, atmcase ) GriddedFieldLatLonExpand( gf3tmp, gf3tmp ) GriddedFieldPRegrid( gf3tmp, p_grid, gf3tmp, interp_order, 1 ) GriddedFieldLatLonRegrid( gf3tmp, lat_grid, lon_grid, gf3tmp, interp_order ) FieldFromGriddedField( edensity_field, p_grid, lat_grid, lon_grid, gf3tmp ) # rereading (since we didn't keep the 3D raw data) and regridding B-field # construct atmcase Extract( basename, basecasearray, 2 ) #now reading and regridding of each of the 3 B-field components separately Copy( atmcase, basename ) StringSet( caseext, ".B_u" ) Append( atmcase, caseext ) ReadXML( gf3tmp, atmcase ) # first: regrid to p_grid GriddedFieldPRegrid( gf3tmp, p_grid, gf3tmp, interp_order, 1 ) # second: regrid to lat/lon_grid GriddedFieldLatLonRegrid( gf3tmp, lat_grid, lon_grid, gf3tmp, interp_order ) # last, extract the data Tensor from the regridded GriddedField FieldFromGriddedField( mag_u_field, p_grid, lat_grid, lon_grid, gf3tmp ) Copy( atmcase, basename ) StringSet( caseext, ".B_v" ) Append( atmcase, caseext ) ReadXML( gf3tmp, atmcase ) # first: regrid to p_grid GriddedFieldPRegrid( gf3tmp, p_grid, gf3tmp, interp_order, 1 ) # second: regrid to lat/lon_grid GriddedFieldLatLonRegrid( gf3tmp, lat_grid, lon_grid, gf3tmp, interp_order ) # last, extract the data Tensor from the regridded GriddedField FieldFromGriddedField( mag_v_field, p_grid, lat_grid, lon_grid, gf3tmp ) Copy( atmcase, basename ) StringSet( caseext, ".B_w" ) Append( atmcase, caseext ) ReadXML( gf3tmp, atmcase ) # first: regrid to p_grid GriddedFieldPRegrid( gf3tmp, p_grid, gf3tmp, interp_order, 1 ) # second: regrid to lat/lon_grid GriddedFieldLatLonRegrid( gf3tmp, lat_grid, lon_grid, gf3tmp, interp_order ) # last, extract the data Tensor from the regridded GriddedField FieldFromGriddedField( mag_w_field, p_grid, lat_grid, lon_grid, gf3tmp ) atmfields_checkedCalc atmgeom_checkedCalc ##### # Winds ##### #reading and regridding of the wind-field components. however, here we only have # data for u-component (zonal), but two different version of them. Extract( basename, basecasearray, 0 ) ### # version 1 Copy( atmcase, basename ) StringSet( caseext, ".wind_u" ) Append( atmcase, caseext ) ReadXML( gf3tmp, atmcase ) # first: regrid to p_grid GriddedFieldPRegrid( gf3tmp, p_grid, gf3tmp, interp_order, 1 ) # second: make 3D fields from 1D, then regrid to lat/lon_grid GriddedFieldLatLonExpand( gf3tmp, gf3tmp ) GriddedFieldLatLonRegrid( gf3tmp, lat_grid, lon_grid, gf3tmp, interp_order ) # last, extract the data Tensor from the regridded GriddedField FieldFromGriddedField( wind_u_field, p_grid, lat_grid, lon_grid, gf3tmp ) atmfields_checkedCalc atmgeom_checkedCalc ### # version 2 Copy( atmcase, basename ) StringSet( caseext, ".wind_u.into-thermal" ) Append( atmcase, caseext ) ReadXML( gf3tmp, atmcase ) # first: regrid to p_grid GriddedFieldPRegrid( gf3tmp, p_grid, gf3tmp, interp_order, 1 ) # second: make 3D fields from 1D, then regrid to lat/lon_grid GriddedFieldLatLonExpand( gf3tmp, gf3tmp ) GriddedFieldLatLonRegrid( gf3tmp, lat_grid, lon_grid, gf3tmp, interp_order ) # last, extract the data Tensor from the regridded GriddedField FieldFromGriddedField( wind_u_field, p_grid, lat_grid, lon_grid, gf3tmp ) atmfields_checkedCalc atmgeom_checkedCalc #WriteXML( "ascii", wind_u_field ) #WriteXML( "ascii", wind_v_field ) #WriteXML( "ascii", wind_w_field ) }