1 / 9

How to Modify Codes: include a new variable

How to Modify Codes: include a new variable. Summary Step 1: make sure if the new variable exist in MODELS and DATA; Step 2: modify read_benchmark.ncl to read the new variable data; Step 3: modify get_benchmark.ncl to load the new data into the system;

parkb
Download Presentation

How to Modify Codes: include a new variable

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. How to Modify Codes: include a new variable Summary Step 1: make sure if the new variable exist in MODELS and DATA; Step 2: modify read_benchmark.ncl to read the new variable data; Step 3: modify get_benchmark.ncl to load the new data into the system; Step 4: modify get_model.ncl to load the correct variable data from models; Step 5: modify input_control_para.ncl to pass right info for the new variable; Step 6: check general_info.ncl for the unit, reference for data; Step 7: check get_DrawInfo.ncl for the unit, title, contour levels for plots; Step 8: modify ILAMB_PARA_SETUP to show up the new variable; Step 9: run and test. Note: Please use CMIP5 naming system and data structure, otherwise you may also need to modify read_model.ncl and read_benchmark to tell the package how to get the new variable from both model and benchmark.

  2. Step 1: make sure if the new variable exists in $ILAMB_ROOT/MODELS and $ILAMB_ROOT/DATA Method Please use CMIP5 naming system and data structure, otherwise you may also need to modify read_model.ncl and read_benchmark to tell the package how to get the new variables from both models and benchmark. You may find the codes to input benchmark data and CMIP5 simulations below: $ILAMB_ROOT/CODES/subroutines/read/read_benchmark.ncl $ILAMB_ROOT/CODES/subroutines/read/get_benchmark.ncl $ILAMB_ROOT/CODES/subroutines/read/read_model.ncl $ILAMB_ROOT/CODES/subroutines/read/get_model.ncl

  3. Step 2: create a function to read the new variable data $ILAMB_ROOT/CODES/subroutines/read/read_benchmark.ncl ;##################################################################function read_snow ( DataDir:string, Source:string, BenchMarkRaw:string, StartYear:integer, EndYear:integer, slat:float, slon:float) begin nyer=EndYear-StartYear + 1 nmon=12 ntot=nyer*nmon nlat=360 nlon=720 ts=new((/ntot,nlat,nlon/), float) ijk=0 do iiy=StartYear, EndYear do iim=1,nmon file_in=DataDir + "/derived/" + sprinti("%0.4i",iiy) + "/albedo_0.5x0.5_" + sprinti("%0.4i",iiy) + sprinti("%0.2i",iim) + ".nc" print(file_in) f1=addfile(file_in, "r”) tmp=f1->albedo slat=f1->lat slon=f1->lon ts(ijk,:,:) = tmp delete(f1) delete(tmp) ijk=ijk+1 end do end do return (ts) end Method Just copy one function and change the function name as your own. If you don’t use raw data for this variable, you can delete that part, and keep the rest. Please check if the file name is correct. Here is an example copied from read_albedo and made a change to read derived snow data.

  4. Step 3: Modify get_benchmark.ncl code to load the new variable data $ILAMB_ROOT/CODES/subroutines/read/get_benchmark.ncl ; #######################################################################; +++++ start to read snow ++++++ if (str_lower(VarName).eq.”snow") then nlat0=360 nlon0=720 slat0=new((/nlat0/), float) slon0=new((/nlon0/), float) if (str_upper(Source).eq."GEWEX.SRB") then ts = read_albedo_gewexsrb (DataDirObs, VarName, BenchMarkRaw, StartYear, EndYear, slat0, slon0) end if if (str_upper(Source).eq."CERES" .or. str_upper(Source).eq."MODIS") then ts = read_snow (DataDirObs, Source, BenchMarkRaw, StartYear, EndYear, slat0, slon0) end if tmp=ts do nt=0, ntot-1 do nx=0, nlon0/2-1 ts(nt,:,nx)=(/tmp(nt,:,nlon0/2+nx)/) ts(nt,:,nlon0/2+nx)=(/tmp(nt,:,nx)/) end do end do delete(tmp) slon0=slon0+180. end if ; +++++ end to read snow ++++++ Method Copy and paste the codes for one variable, for example albedo in the code get_benchmark.ncl. Make change to load the new function read_snow and check if any input parameter is wrong especially the source name. You may also convert the unit here, the unit you want to show in the html files.

  5. Step 4: modify the code to convert the unit for the model $ILAMB_ROOT/CODES/subroutines/read/get_model.ncl ……. ; ++++ convert co2's unit from mol/mol to ppm ++++ if (str_lower(VarName).eq."co2") then ts1=ts1*1.0e6 end if ; ++++ convert et's unit from Kg/m2/s to mm/day ++++ if (str_lower(VarName).eq."et") then ts1=ts1*24*3600.0 end if ; ++++ convert pr's unit from Kg/m2/s to mm/day ++++ if (str_lower(VarName).eq."pr") then ts1=ts1*24*3600.0 end if …………. Method Copy and paste the code for a variable, and make change to get right unit conversion. If the new variable is derived from other variables, you need make a copy like this showed in the left. ……. if (str_lower(VarName).eq."albedo") then ts1=read_model_vars (DataDirMod, cmipID, modelID, expID, runID, "rsds") ts2=read_model_vars (DataDirMod, cmipID, modelID, expID, runID, "rsus") ts1=where(ts1.eq.0, -999, ts1) ts1=ts2/ts1 delete(ts2) end if ………….

  6. Step 5: Modify input_control_para.ncl to pass right info for the new variable data $ILAMB_ROOT/CODES/subroutines/diagnostics/input_control_para.ncl Method Copy and paste a part for some variable, for example albedo in the code input_control_para.ncl. Make change to pass the right information for the new variable, such as source, variable names in data and model, start and end of years for the data. ; ++++++ Set parameters for albedo diagnostics +++++ if (str_lower(VarNameList(nv)).eq."albedo") then Source = "CERES,MODIS" BenchMarkRaw = "no" ModelRaw = "yes" StartYear = "2000,2000" EndYear = "2005,2005" Var = "albedo" VarModel = "rsds" expID = "historical" modelID = "Amon" strings = "" VarUnit = general_info("Unit", Var, strings) delete(strings) end if

  7. Step 6: check general_info.ncl for the unit, reference for data, long variable … $ILAMB_ROOT/CODES/subroutines/general/general_info.ncl Method Copy, paste and modify the code to provide the correct unit, reference for data, long variable name and category. This information will be showed in the html files.

  8. Step 7: check get_DrawInfo.ncl for the unit, title, contour levels $ILAMB_ROOT/CODES/subroutines/draw/get_DrawInfo.ncl Method Copy, paste and modify the code to provide the correct unit, title and contour. This information will be showed in the plots for annual mean, bias and rmse.

  9. Step 8. Change Control Parameter File to show up the new variable

More Related