[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

20051024: Example pqact.conf entry for dealing with bzip2 unccompression



>From: Matthew Lazzara <address@hidden>
>Organization: SSEC/AMRC
>Keywords: 200510241755.j9OHt17s014043 ldm-mcidas area2png pnga2area

Hi Matthew,

>Hello! Question for you - o.k.  Make it two:
>
>1.  Can you point me to a resource to start learning/getting the code  
>for png2area and area2png ?

Both of these routines are available in binary and source ldm-mcidas
distributions.  The first thing you will want to do is get an
ldm-mcidas binary distribution built to run on the OS on which you will
do the image injection.  The ldm-mcidas binary and source distributions
are available by anonymous FTP as follows:

machine:   ftp.unidata.ucar.edu
user:      anonymous
pass:      address@hidden

binary::
directory: pub/binary/<relevant OS>

source:

directory: ldm-mcidas

The file name in both cases is the same, ldm-mcidas-2004.tar.Z.

To get help for how area2png is run, simply execute its binary
once you have downloaded ldm-mcidas and unpacked it on the target
OS.  Running area2png with no arguments results in a listing
of options that are supported.

The way I use 'area2png' is as follows:

- somehow get a McIDAS AREA file written into a specific file

- run 'area2png' to compress the file and name it based on
  information in the AREA file header.  This name will look
  strange to folks used to Unix file names, but don't worry.

- use pqinsert to insert the compressed file into the LDM
  product queue using the file name as the metadata for the
  product.  This is why I write the compressed image out to
  a file with a long name.
  
Since 'area2png' can be run by hand, you can get an idea of
what it can do and output file names it can make.  Once you
have something you like, you can put its invocation into a script
to make things tidy.

Just so you know...  You can also specifiy the name of the output
file in your 'area2png' invocation; you don't have to let it
decide on the output name.

If you want some guidance on how to setup and use area2png, perhaps
we could get together for a half hour or so while I am in Madison
for the MUG meeting later this week.

>2.  Do you have or know of any pqact.conf examples of take products  
>on IDD that are compressed and uncompresses them?

Most are embodied in special purpose routines (executables) that
support reading from STDIN and writing to a specified file, so
I don't think that these would be helpful.

>Should we write a  
>script to take in the product, uncompress it and file it away or can  
>you do that on a single line of a pqact.conf entry?? (I'm thinking  
>using PIPE action and piping the product to gunzip or bunzip2 and  
>"piping" the output to a directory - does that work?

This is what I would do to start.  The following is the source
for a simple Bourne shell script I wrote some time ago that will
write the Zlib-compressed NOAAPORT GINI images to a user-specified
directory AND write log output to a log file.  I would use this
script as an example that can be modified to do what you want.

-------------  ldmfile.sh  ----------------------------

#!/bin/sh -f

#--------------------------------------------------------------------------
#
# Name:    ldmfile.sh
#
# Purpose: file a LDM product and log the receipt of the product
#
# Note:    modify the 'LOG' file to suit your needs
#
# History: 20030815 - Created for Zlib-compressed GINI image filing
#
#--------------------------------------------------------------------------

SHELL=sh
export SHELL

# Set log file
LOG=~ldm/logs/ldm-mcidas.log
exec >>$LOG 2>&1

# Create directory structure
fname=`basename $1`
dirs=`echo $1 | sed s/$fname//`
mkdir -p $dirs

# Write stdin to the designated file and log its filing
echo `date -u +'%b %d %T'` `basename $0`\[$$\]: FILE $1
cat > $1

# Done
exit 0

-------------  ldmfile.sh  ----------------------------

So, let's review what ldmfile.sh does:

- accepts a fully qualified name for the output file; this is passed in
  on the invocation command line and picked up as '$1'

- it sets a log file to log to and makes sure that all log output
  will go to that file:

# Set log file
LOG=~ldm/logs/ldm-mcidas.log
exec >>$LOG 2>&1

- creates the output directory 

# Create directory structure
fname=`basename $1`
dirs=`echo $1 | sed s/$fname//`
mkdir -p $dirs

- writes log information to the log file:

echo `date -u +'%b %d %T'` `basename $0`\[$$\]: FILE $1

- writes the product to a file on disk:

cat > $1


OK, once you have done this, you could run bzip2 on the file and
uncompress it.  Here is one idea of how you might do this:

-------------  fileandunbzip.sh  ----------------------------

#!/bin/sh -f

#--------------------------------------------------------------------------
#
# Name:    fileandunbzip.sh
#
# Purpose: file a bzip2-compressed LDM product into a temporary file and
#          then uncompress it while logging the receipt of the product
#
# Note:    modify the 'LOG' file to suit your needs
#
# History: 20051024 - Created as an example of bzip2 product uncompression
#
#--------------------------------------------------------------------------

SHELL=sh
export SHELL

# Set log file
LOG=~ldm/logs/antarctic-idd.log
exec >>$LOG 2>&1

# Create directory structure
fname=`basename $1`
dirs=`echo $1 | sed s/$fname//`
mkdir -p $dirs

# Write stdin to the designated file and log its filing
cat > $1.bzip2

# Uncompress the bzip2-compressed file
echo `date -u +'%b %d %T'` `basename $0`\[$$\]: FILE $1
bunzip2 -c $1.bzip2 > $1

# Done
exit 0

-------------  fileandunbzip.sh  ----------------------------

The nice thing about the script is that you can play with it from
the Unix/Linux command line until you get it the way you want it.

After it is working, add one or more entries to your pqact.conf
file to execute it.  As an example, here is a pqact.conf entry
that executes ldmfile.sh for NOAAPORT GINI images:

# Zlib compressed NOAAPORT GOES-East/West GINI Images -- FILE
NIMAGE  ^satz/ch[0-9]/.*/(.*)/([12][0-9][0-9][0-9][01][0-9][0-3][0-9]) 
([0-2][0-9])([0-5][0-9])/(.*)/(.*km)/
        PIPE    -close
        util/ldmfile.sh data/pub/native/satellite/\1/\5_\6/\2/\5_\6_\1_\2_\3\4.g

NOTE:

- some whitespaces in pqact.conf actions are tabs, not spaces.  This
  is IMPORTANT!!!:

NIMAGE  ^satz
       ^_ tab, not a space!!!!

        PIPE    -close
   ^          ^_______ tab
   |__________________ tab

        util/ldmfile.sh
   ^__________________ tab

When I say use a tab, I mean use one or more tabs and _no_ spaces.

>Thank you Tom!

No worries.

>See you at MUG meeting on Thursday?
 
Yup, see you there.

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.