From:	IN%"hairston@utdallas.edu"  "Marc R Hairston" 13-NOV-1995 23:02:42.51
To:	IN%"David.Steele@sask.usask.ca"
CC:	IN%"hairston@utdallas.edu"
Subj:	Longfile reading template

Return-path: <hairston@utdallas.edu>
Received: from skycat.usask.ca by SKISAS.USask.CA (PMDF V4.2-11 #3676) id
 <01HXM14GRF1C9D6N4R@SKISAS.USask.CA>; Mon, 13 Nov 1995 23:02:26 GMT
Received: from utdallas.edu by SKYCAT.USask.CA (PMDF V4.3-11 #5952) id
 <01HXLOJWCJLC935RQG@SKYCAT.USask.CA>; Mon, 13 Nov 1995 17:02:15 -0600 (CST)
Received: from localname (csssun10.utdallas.edu [129.110.7.6]) by utdallas.edu
 (8.6.11/8.6.11) with ESMTP id RAA26342; Mon, 13 Nov 1995 17:02:11 -0600
Date: Mon, 13 Nov 1995 17:02:08 -0600
From: Marc R Hairston <hairston@utdallas.edu>
Subject: Longfile reading template
To: David.Steele@sask.usask.ca
Cc: hairston@utdallas.edu
Message-id: <199511132302.RAA26342@utdallas.edu>
X-Envelope-to: STEELE
MIME-version: 1.0
X-Mailer: exmh version 1.5.3 12/28/94
Content-type: text/plain; charset="us-ascii"
Content-transfer-encoding: 7BIT

Hi David,
   Below is the template that we use for reading the HDF longfiles here
on our VAX.  You can use this to get the formats and units information
for your own use.  We've got six northern passes during your time period.  
   Quick explanation here. We have trouble with the baseline zero for
the flows (particularly the horizontal flows).  What we do is try to
automatically find a good point at either end of the pass (nominally
somewhere about 55 or 50 degrees magnetic latitude, though it can be
outside of this region) where the flow is steady and close to zero.
We take the average of those two and define *that* as the zero baseline
and do a DC shift of all the flow data.  The DC shift is saved as the
two constants CHF and CVF. In other words we rezero the baseline for
each and every pass. For the first three passes the program did
find endpoints, but the duskside one of all three them is too far south 
and really should be around 50 degrees.  For the last three, it couldn't 
find a suitable endpoint and so the data is simply the flows as seen 
by the spacecraft and the CHF and CVF are zero.  The moral of this story 
is that you can feel free to slide the baseline around a bit to get what
you consider to be a good zero baseline for your work.
   One last thing, the files will be mailed from the DMSP account.  If you 
have questions, write to me, not to DMSP as I won't see the mail there.
Have fun!
Marc
  


*****************************************************************************
*  August 1995  READ LONGfiles HDF TEMPlate .FOR
*  This is the template for reading the HDF (heirarchal data format) long
*  files produced by the DMSPDBASE4AHDF processing program.  This file 
*  contains the data from half an orbit (equator pass to next equator pass).
*  The first line contains the SFINDEX number and the IMF and Kp data
*  and the number of lines of data remaining in the file (IMAX) which
*  is nominally 810.  Each of the next IMAX lines contains the drift data
*  (horizontal and vertical), their standard deviations (for each), the 
*  calculated electrstatic potential (in the polar regions, otherwise this
*  is zero), and the spacecraft's location in geomagnetic and geographic
*  coordinates.  These data are at 4 second resolution. 
*
*  link this with user:[dmsp.hdf.lib]df/lib
*
*******************************************************************************

      dimension vy(900),vz(900),stdevy(900),stdevz(900)
      dimension xutime(900),nmbpts(900),potlng(900)
      dimension scmlat(900),scmlats(900),scmltm(900)
      dimension scinvlat(900),scglat(900),scglong(900)

      integer*4 rank,maxrank,dimsize(2)
      character*80 inputfile

      real*4 headerbuffer(17)
      real*4 buffer(13,850)

 1001 format (A80)

      type *,' enter path and name of input file'
      accept 1001,inputfile

c  read in the header line
      maxrank=2
      call DFSDgetdims(inputfile,rank,dimsize,maxrank)
      call DFSDgetdata(inputfile,rank,dimsize,headerbuffer)

c  Here is a list of the data in the first line of the file

c  variable name	data
c =========================================================================
c  isatid		satellite number (8,9,10,11,12,13,...)
c  iyr			year   (at the start of the this pass at equator) 
c  iday			day    (at the start of the this pass at equator) 
c  ihr			hour   (at the start of the this pass at equator) 
c  imin			minute (at the start of the this pass at equator) 
c  ****** isatid/iyr/iday/ihr/imin = sfindex number for this pass  ********
c  bxprev		IMF X hourly average\
c  byprev		IMF Y hourly average |-during hour BEFORE pass started
c  bzprev		IMF Z hourly average/
c  bxstrt		IMF X hourly average\
c  bystrt		IMF Y hourly average |-during hour that pass STARTED
c  bzstrt		IMF Z hourly average/
c  bxstop		IMF X hourly average\
c  bystop		IMF Y hourly average |-during hour that pass ENDED
c  bzstop		IMF Z hourly average/
c *NOTE: all the IMF data are in nT
c *NOTE: depending on the time, starting and stopping IMF data may be the same*
c *NOTE: all IMF hourly averages come from the NSSDC OMNI datafiles*
c  kpstrt		Kp at the start of the pass
c  kpstop		Kp at the end of the pass
c *NOTE: almost all the starting and stopping Kp values will be the same
c  chf			the correction factor applied to the Vy data (km/s)
c  cvf			the correction factor applied to the Vz data (km/s)
c *NOTE: For the potential calculations, the algorithm attempts to rezero
c  the baseline of the flow data, and the program saves the rezeroed flow
c  data.  Thus, to get the orginal measured flow data, you simply add the
c  appropriate correction factor back to all the data points in the flow array.
c  e.g. horizontal flow measured by DMSP = Vy (i) + chf
c         vertical flow measured by DMSP = Vz (i) + cvf


      isatid=headerbuffer(1)
      iyd=headerbuffer(2)
      iyr=iyd/1000
      iday=iyd-(iyr*1000)
      ihm=headerbuffer(3)
      ihr=ihm/60
      imin=ihm-(ihr*60)
      bxprev=headerbuffer(4)
      byprev=headerbuffer(5)
      bzprev=headerbuffer(6)
      bxstrt=headerbuffer(7)
      bystrt=headerbuffer(8)
      bzstrt=headerbuffer(9)
      bxstop=headerbuffer(10)
      bystop=headerbuffer(11)
      bzstop=headerbuffer(12)
      kpstrt=headerbuffer(13)
      kpstop=headerbuffer(14)
      imax=headerbuffer(15)
      chf=headerbuffer(16)
      cvf=headerbuffer(17)

c  read in the data itself
      call DFSDgetdims(inputfile,rank,dimsize,maxrank)
      call DFSDgetdata(inputfile,rank,dimsize,buffer)


c  Here is a list of the data in the datafile

c  variable name	data
c =========================================================================
c   xutime		time of day in seconds (one line of data every 4 sec)
c   Vy			4 second averaged horizontal ion flow data (km/s)
c   Vz			4 second averaged vertical ion flow data (km/s)
c   stdevy		standard deviation of the averaged horizontal ion flow
c   stdevz		standard deviation of the averaged vertical ion flow
c   nmbpts		number of points in the 4 second average (nominal 24)
c   potlng		electrostatic potential calculated at this point
c * NOTE: This is the corrected potential so both ends are zero.  And the
c   data are all zero except in the polar region. 
c   scmlat		magnetic latitude at 110 km (degrees)
c   scmlats		magnetic latitude at the satellite (degrees)
c   scmltm		magnetic local time at 100 km (decimal hour)
c   scinvlat		invariant latitude (degrees)
c   scglat		geographic latitude of the spacecraft (degrees)
c   scglong		geographic east longitude (degrees)

      do 100 i=1,imax
      xutime(i)=buffer(1,i)
      vy(i)=buffer(2,i)
      vz(i)=buffer(3,i)
      stdevy(i)=buffer(4,i)
      stdevz(i)=buffer(5,i)
      nmbpts(i)=buffer(6,i)
      potlng(i)=buffer(7,i)
      scmlat(i)=buffer(8,i)
      scmlats(i)=buffer(9,i)
      scmltm(i)=buffer(10,i)
      scinvlat(i)=buffer(11,i)
      scglat(i)=buffer(12,i)
      scglong(i)=buffer(13,i)
  100 continue

      end


