Difference between revisions of "GAMAP tips and tricks"

From Geos-chem
Jump to: navigation, search
(GAMAP and IDL 7)
(GAMAP Tips and Tricks)
(93 intermediate revisions by 2 users not shown)
Line 1: Line 1:
On this page we list some very helpful tips on how to accomplish various tasks with the GAMAP routines.
+
On this page we list information about GAMAP, the Global Atmospheric Model Analysis Package.
  
== GAMAP and IDL 7 ==
+
== Overview ==
  
Version 7 of IDL comes with a new development environment (called workbench) based on Eclipse. If you are not using the IDL workbench, you will not notice any change. But if you do, you will see a major upgrade, ... and may soon have a problem with the !PATH definition. For GAMAP to work properly, we provide an idl_startup.pro template file for you to modify for your system. In this routine, you used to see the !PATH defined like that:
+
GAMAP
  
IdlPath = Expand_Path( '+' + !PATH,  /All_Dirs )  
+
* is a self-contained, consistent, and user-friendly software package for reading and visualizing output from chemical tracer models (CTM's)
+
* consists of a suite of routines written in IDL (Interactive Data Language)
!PATH      = EXPAND_PATH('+~/IDL/dvpt/')             + ':' + $
+
* makes extensive use of IDL's powerful plotting features
              EXPAND_PATH('+~/IDL/gamap2/', /ALL_DIRS) + ':' + $
+
* can produce line plots, 2D plots, 2D animations, or 3D isocontour surface plots
              EXPAND_PATH('+~/IDL/idlpro/')           + ':' + $
+
* can read 2D, 3D or 4D data blocks
              '~/IDL/jhuapl/'                          + ':' + $
+
* can read output from the GEOS–Chem, GISS and FSU model families
              IdlPath
+
* can be easily customized to keep pace with ongoing model development
 +
* can be installed on any platform that supports IDL, thus ensuring a high degree of portability
 +
* can be coupled with the ION (IDL on the Net) interface to create interactive plots which can be served to a web page
 +
* can read data from ASCII, binary, netCDF (including COARDS conventions!), and HDF–EOS file formats
 +
* contains helper routines to read from / write to various file formats
  
Now, for GAMAP to work with the new IDLDE, you must use the following syntax instead:
+
The main GAMAP program contains a user-friendly, menu-driven interface; however, users may also call GAMAP subroutines independently of the main program. This makes it possible to embed GAMAP routines within existing IDL code.
  
PREF_SET, 'IDL_PATH',                              $
+
== Table of Contents ==
            EXPAND_PATH('+~/IDL/dvpt/'              ) + SEP + $
+
            EXPAND_PATH('+~/IDL/gamap2/', /ALL_DIRS ) + SEP + $
+
            EXPAND_PATH('+~/IDL/idlpro/'            ) + SEP + $
+
            '~/IDL/jhuapl/'                          + SEP + $
+
            '<IDL_DEFAULT>', /COMMIT
+
  
Note that it can be used even if you do not use the workbench. More about that issue can be found [http://www.dfanning.com/workbench/pathfromhell.html here].
+
=== GAMAP web pages ===
  
NOTE: The PREF_SET command was introduced in IDL 6.2.
+
This page has now been split into several sub-pages:
  
--[[User:Plesager|phs]] 16:42, 14 April 2008 (EDT)
+
* [http://acmg.seas.harvard.edu/gamap/ GAMAP main page]
 +
* [http://acmg.seas.harvard.edu/gamap/doc/index.html GAMAP Online User's Guide]
  
== Making movies from GAMAP output ==
+
=== GAMAP tips and tricks ===
  
The best way to make movies with GAMAP is to save out individual frames as GIF images, and then use a 3rd-party GIF utility to concatenate those into an animated GIF.
+
* [[General GAMAP usage]]
 +
* [[File I/O with GAMAP]]
 +
* [[Color and graphics with GAMAP]]
 +
* [[Regridding with GAMAP]]
 +
* [[Date and time computations with GAMAP]]
 +
* [[Text manipulation with GAMAP ]]
 +
* [[Removing extraneous lines from map plots]]
  
=== GIFsicle ===
+
--[[User:Bmy|Bob Y.]] 09:48, 11 March 2011 (EST)
 
+
You can obtain the GIFsicle distribution from [http://www.lcdf.org/gifsicle/ http://www.lcdf.org/gifsicle/].  When you build gifsicle, the following executables will be created:
+
 
+
;gifsicle: Utility to concatenate individual GIFs into an animated GIF.  Can also be used to extract individual frames from an animated GIF image.
+
;gifview: A lightweight GIF viewer for X. It can display animated GIFs as slideshows, one frame at a time, or as animations.
+
;gifdiff: Compares two GIF images for identical visual appearance
+
 
+
Using GIFsicle to create an animated GIF from individual GIF's:
+
 
+
gifsicle --delay=10 --loop *.gif > anim.gif
+
 
+
=== WhirlGIF ===
+
 
+
You can obtain WhirlGIF from [http://hpux.cs.utah.edu/hppd/hpux/Networking/WWW/whirlgif-3.04/ http://hpux.cs.utah.edu/hppd/hpux/Networking/WWW/whirlgif-3.04/.]
+
 
+
Using WhirlGIF to create an animated GIF from individual GIFs:
+
 
+
whirlgif -loop -time 10 -o anim.gif *.gif
+
 
+
=== ImageMagick ===
+
 
+
'''''Philippe Le Sager (plesager@seas.harvard.edu) wrote:'''''
+
 
+
: You can also use "convert" at the command line to get animated GIF.  This is a powerful command line, but the basic for animated gif is:
+
 
+
      convert -delay 20 image.* image.gif
+
 
+
:You need to be in the proper directory. The input images are numbered like image.01, image.02, and so on. If the image file names differ too much you will have to explicitly type them, before the output file name, which is last). The delay is the time interval. I think it is in ms.
+
 
+
:You can get more info and tips at:
+
:* [http://www.imagemagick.org/Usage/ http://www.imagemagick.org/Usage/]
+
:* [http://www.imagemagick.org/script/convert.php http://www.imagemagick.org/script/convert.php]
+
 
+
''NOTE: GIFsicle, WhirlGIF, and ImageMagick have already been installed on the Harvard Linux machines.''
+
 
+
--[[User:Bmy|Bmy]] 15:50, 9 April 2008 (EDT)
+
 
+
== Usage of TRACERINFO.DAT and DIAGINFO.DAT ==
+
 
+
User A said he keeps getting this message:
+
% UPDATE_TRACER_DATAINFO: WARNING: Use_DataInfo appears independent from global array!
+
 
+
User B said:
+
:My ctm.bpch files have duplicate data blocks for some parameters. Something's wrong!
+
 
+
Answer:
+
 
+
These are symptoms of diaginfo.dat or/and tracerinfo.dat that do not match the binary punch file (user B), or that the bpch file was created with inadequate diag/tracerinfo.dat files and end up with duplicate 999 tracers without tracername for example (user B). The solution is to use correct diag/tracerinfo.dat when reading and creating bpch files. GEOS-Chem now writes those files for each runs in your run directory. If you use them when reading run outputs, you will not have a problem.
+
 
+
The first time a GAMAP routine is used, it will look for and read these files. First, in the current directory, then in the !path variable (which means it will used the default ones in ../gamap2/input_files/).
+
So, to read those corresponding to your run you can:
+
 
+
# start your IDL session in your run directory
+
# start your IDL anywhere, and then: cd, 'your_run_directory', ''before using GAMAP''
+
# copy your diag/tracerinfo.dat from your run dir to your ../gamap2/input_files/ (i.e., overwrite default ones), ''before using GAMAP''
+
# Advance users can also, at anytime in their session, force GAMAP to read specific diag/tracerinfo.dat:
+
ctm_diaginfo, /all, /force_reading, filename='your_diaginfo.dat'
+
ctm_tracerinfo, /all, /force_reading, filename='your_tracerinfo.dat'
+
 
+
If you are using a default location, double check that it is really used with the following query:
+
print, file_which('tracerinfo.dat')
+
--[[User:Plesager|phs]] 15:52, 4 April 2008 (EDT)
+
 
+
== Date and time ==
+
 
+
This section has been split off into its own wiki page, [[Date and time computations with GAMAP|''Date and Time Computations with GAMAP'']].
+
 
+
== Renaming and Regridding APROD/GPROD restart files ==
+
 
+
When using secondary aerosols, you need a restart_aprod_gprod.YYYYMMDDhh file. Unlike the general restart file used for GEOS-Chem runs, it cannot be simply renamed and ready to use for another simulation date.
+
 
+
=== Renaming APROD/GPROD restart files ===
+
 
+
You must rewrite you restart_gprod_aprod.YYYYMMDDhh so that the date in the filename is the same as the one in the datablock headers. A new routine in GAMAP v2.12 will do it for you:
+
../gamap2/date_time/rewrite_agprod.pro
+
 
+
=== Regridding APROD/GPROD restart files ===
+
 
+
You can regrid a 2ndary aerosol restart file with the same routines used to regrid the standard restart file. However you need to tell the routines to regrid all tracers with the keyword diagn=0 (which means "all tracers"):
+
 
+
regridh_restart, ..., diagn=0
+
regridv_restart, ..., diagn=0
+
 
+
--[[User:Plesager|phs]] 14:51, 4 April 2008 (EDT)
+
 
+
 
+
 
+
 
+
== Combining output from timeseries files ==
+
 
+
'''''Ray Nassar (ray@io.as.harvard.edu) wrote:'''''
+
 
+
:I just have a quick question, is there any GAMAP routine that can average all hourly data blocks in a timeseries file to make a single daily average bpch file? 
+
 
+
:It appears like I could use the average option of ctm_sum.pro but I do not quite understand where the averaged data goes and afterwards would still have to write to bpch.
+
 
+
'''''Philippe Le Sager (plesager@seas.harvard.edu) replied:'''''
+
 
+
:Check the
+
 
+
    /gamap2/timeseries/gc_combine_nd49.pro
+
    /gamap2/timeseries/gc_combine_nd48.pro
+
 
+
:routines, which combines daily bpch files (nd48 & nd49 output, but also met field input files) into 4D data blocks. It has many options. You can extract a subset of data according to time and/or location, or process the data (moving average, daily max, shift to local time). You can either save the data into a new bpch file or just get an array of data in output.
+
 
+
:I wrote a tutorial that gives some pointers [http://www-as.harvard.edu/chemistry/trop/gamap/doc/timeseries_brief_tutorial.pdf here.]
+
 
+
:-Philippe
+
 
+
--[[User:Bmy|Bmy]] 09:43, 1 April 2008 (EDT)
+
 
+
== Memory management and CTM_MAKE_DATAINFO ==
+
 
+
When using CTM_MAKE_DATAINFO, you create few pointers and allocate memory to pointed data. Three scenarios to free that memory are possible.
+
 
+
(1) By default, GAMAP keeps track of the pointers in a global structure, and you can clean up the memory by calling CTM_CLEANUP (with or without the keyword /NO_GC):
+
 
+
    ctm_make_datainfo(data, ...)
+
    CTM_WriteBpch, DataInfo, FileInfo, FileName=file
+
    ctm_cleanup
+
 
+
(2) If you use the keyword /NO_GLOBAL when calling CTM_MAKE_DATAINFO, the story is a little bit more subtle. Now, GAMAP has no idea of the created pointers. If you use CTM_CLEANUP without the keyword /NO_GC, everything is clean up because there is a call to heap_gc. But you are also loosing **all other** pointers and objects.
+
 
+
    ctm_make_datainfo(data, ..., /No_global)
+
    CTM_WriteBpch, DataInfo, FileInfo, FileName=file
+
    ctm_cleanup
+
 
+
Note if you do not call ctm_cleanup or call it with /No_GC, then the memory allocated by CTM_MAKE_DATAINFO is still allocated and the pointers that refers to it are alive... until you exit the routine (unless they are passed back). Once you are out of the routine, this memory remains allocated but is useless since unaccessible, in other words you have memory leak.
+
 
+
(3) So, if you want to keep some objects and/or pointers alive in your code (i.e., you do not want to call heap_gc or ctm_cleanup,/no_gc), you need to free only the created pointers as follows:
+
 
+
    ctm_make_datainfo(data, datainfo, fileinfo, ..., /No_global)
+
    CTM_WriteBpch, DataInfo, FileInfo, FileName=file
+
    ptr_free, DataInfo.data
+
    ptr_free, fileinfo.gridinfo
+
 
+
To free only the heap memory created by multiple calls to CTM_MAKE_DATAINFO, the procedure is:
+
 
+
  for D=0L, NTracers-1L do begin
+
     
+
      Success = CTM_Make_DataInfo( Data[*,*,D], DataInfo, FileInfo, ..., /No_Global )
+
     
+
      ArrDataInfo = D eq 0l ? [ DataInfo ] : [ ArrDataInfo, DataInfo ]
+
     
+
      if D ne Ntracers-1l then ptr_free, Fileinfo.gridinfo
+
     
+
  endfor
+
     
+
  CTM_WriteBpch, ArrDataInfo, FileInfo, FileName=OutFileName
+
     
+
  for d=0, n_elements(ArrDataInfo)-1l do ptr_free, ArrDataInfo[d].data
+
  ptr_free, fileinfo.gridinfo
+
 
+
--[[User:Plesager|phs]] 10:28, 13 February 2008
+

Revision as of 14:49, 11 March 2011

On this page we list information about GAMAP, the Global Atmospheric Model Analysis Package.

Overview

GAMAP

  • is a self-contained, consistent, and user-friendly software package for reading and visualizing output from chemical tracer models (CTM's)
  • consists of a suite of routines written in IDL (Interactive Data Language)
  • makes extensive use of IDL's powerful plotting features
  • can produce line plots, 2D plots, 2D animations, or 3D isocontour surface plots
  • can read 2D, 3D or 4D data blocks
  • can read output from the GEOS–Chem, GISS and FSU model families
  • can be easily customized to keep pace with ongoing model development
  • can be installed on any platform that supports IDL, thus ensuring a high degree of portability
  • can be coupled with the ION (IDL on the Net) interface to create interactive plots which can be served to a web page
  • can read data from ASCII, binary, netCDF (including COARDS conventions!), and HDF–EOS file formats
  • contains helper routines to read from / write to various file formats

The main GAMAP program contains a user-friendly, menu-driven interface; however, users may also call GAMAP subroutines independently of the main program. This makes it possible to embed GAMAP routines within existing IDL code.

Table of Contents

GAMAP web pages

This page has now been split into several sub-pages:

GAMAP tips and tricks

--Bob Y. 09:48, 11 March 2011 (EST)