This archive contains answers to questions sent to Unidata support through mid-2025. Note that the archive is no longer being updated. We provide the archive for reference; many of the answers presented here remain technically correct, even if somewhat outdated. For the most up-to-date information on the use of NSF Unidata software and data services, please consult the Software Documentation first.
>From: "Mekonnen Gebremichael" <address@hidden> >Organization: Pratt School of Engineering, Duke University >Keywords: 200504201601.j3KG1gv2005753 McIDAS probing image values Hi Mekonnen, re: processing of global composite IR images >I wrote a script in KSH to do the job. In order to loop through each >dataset, I am planning to vary POS (starting form 1 until the last number of >files) in the imgcopy.k statement. Sounds tood. >Could you see the script I attached and give me your feedback. Sure. My comments are intermixed with the script below. #!/bin/ksh The first thing I would consider doing in the script is define all environment variables needed by McIDAS. If you are logged in to an interactive Unix session where these variables are already defined, this is not needed. If, however, you decide sometime later that you want to run the script from a cron job (for instance, you find that you will be doing the processing on a regular basis), then you want the script to be self contained. I provide two example shell scripts in the McIDAS distribution to help users develop their own scripts: ~mcidas/data/mcrun.sh ~mcidas/data/mcbatch.sh These scripts are designed to be copied to some other name and then edited to match the user's need. In particular, they have the statements used for defining all needed environment variables. dsserve.k ADD IRjd183/AREA AREA DIRFILE=/disk/space/mek11/USdata/compIR/183/globir.02183.\* \"Global IR You only need to define the dataset once so this could be done outside of your script if you are going to be running the script from an interactive Unix session. It does no harm to define the dataset more than once, however, so there is nothing wrong with what you are doing. redirect.k ADD globir.\* \"/disk/space/mek11/USdata/compIR/183 Like defining the dataset, defining a REDIRECTion only needs to be done once. Also like defining the dataset, there is no harm in redefining the REDIRECTion. For reference, the persistent "backing store" for dataset definitions and REDIRECTions are: DSSERVE definitions are saved in the file $MCDATA/RESOLV.SRV REDIRECT definitions are saved in the file $MCDATA/LWPATH.NAM Both of these files are used each time you run a McIDAS session as long as you have defined the needed environment variables: MCPATH - defines the search path of directories for McIDAS when it is looking for data and ancillary data files MCTABLE_READ - defines the set of server mapping tables (created by DATALOC) to read to figure out where (on which server) a dataset is located MCTABLE_WRITE - defines the single file to write when specifying a server mapping (DATALOC command) dmap.k globir Just to be sure? Good idea :-) for i in 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 do for j in 15 45 do lwu.k POKE globir.02183.$i$j 0 56 lwu.k POKE globir.02183.$i$j 0 57 done done I am no KSH scripting expert, so I will assume that this is the correct syntax for KSH do loops. y=1 for i in 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 do for j in 15 45 do echo $y imgcopy.k IRjd183/AREA.1 MYDATA/IMAGES.3000 LATLON 39 100 SIZE=200 400 POS=$y axform.k 3000 IR183$i$j FTYPE=ASC NAV=YES UNIT=TEMP done let y=y+1 done print "Script done" There is no 'POS' keyword for the IMGCOPY command. I would change the loop to increment the output position specified: y=1 pos=3000 for i in 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 do for j in 15 45 do echo $y imgcopy.k IRjd183/AREA.$y MYDATA/IMAGES.$pos LATLON 39 100 SIZE=200 400 axform.k $pos IR183$i$j FTYPE=ASC NAV=YES UNIT=TEMP done let y=y+1 let pos=pos+1 done This will make a unique image sector from each original. -- OR -- y=1 for i in 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 do for j in 15 45 do echo $y imgcopy.k IRjd183/AREA.$i MYDATA/IMAGES.3000 LATLON 39 100 SIZE=200 400 axform.k 3000 IR183$i$j FTYPE=ASC NAV=YES UNIT=TEMP done let y=y+1 done This uses a single output file (AREA3000), so it uses less disk space. So, it looks like your script is pretty much done! I recommend taking a look at the example shell scripts in the McIDAS distribution for some ideas on setting the needed environment variables just in case you decide to start running the script from cron. Cheers, Tom -- NOTE: All email exchanges with Unidata User Support are recorded in the Unidata inquiry tracking system and then made publicly available through the web. If you do not want to have your interactions made available in this way, you must let us know in each email you send to us.