[Previous]
[Next]
NAME:
Rank
PURPOSE:
Construct rank table from given index table.
CATEGORY:
Math: sorting
CALLING SEQUENCE:
subroutine Rank(N1,N2,M1,M2,INDX,IRANK)
INPUTS:
N1,N2 integer physical dimensions of arrays INDX and IRANK
M1,M2 integer logical dimensions of arrays INDX and IRANK
(only the logical part of INDX is ranked)
INDX(M1:M2)
integer index table for a one-dimensional array
ARRIN(M1:M2) (obtained from subroutine Index??)
OUTPUTS:
IRANK(M1:M2)
integer rank table
SIDE EFFECTS:
The part of the rank array IRANK outside the logical range
(i.e. [M1:N1-1] and [N2+1,M2]) remains untouched
RESTRICTIONS:
The index range [N1,N2] must be a subset of [M1,M2]
SEE ALSO:
IndexI4, Sort2I4, SortI4
PROCEDURE:
The index values [N1,N2] are arranged in IRANK(N1:N2) in such a way
that IRANK(J) gives the rank of the element ARRIN(J), i.e. N1 if
ARRIN(J) is the smallest element in the range [N1,N2]; and N2 if it is
the largest.
See Press et al., "Numerical Recipes", Cambridge UP (1989), Chapter 8,
p. 234
MODIFICATION HISTORY:
1990, Paul Hick (UCSD)
[Previous]
[Next]
NAME:
RClean
PURPOSE:
Cleans 'dirty' or 'NaN' REAL*4 zeros
CATEGORY:
gen/for/lib
CALLING SEQUENCE:
subroutine Rclean (idirty, iclean)
INPUTS:
X real value to be checked
OUTPUTS:
X real set to zero if it was a dirty zero
I integer 0: if the was not modified
1: if the input was set to zero
CALLS:
(none)
SEE ALSO:
Clean0, iClean0, iCleanNaN
RESTRICTIONS:
Should be called with REAL*4 argument!
PROCEDURE:
A dirty zero is tested by the condition
iand(idirty,Z'0000FF80') .eq. 0
The NaN value is tested by
iand(idirty,Z'0000FF80') .eq. 0
MODIFICATION HISTORY:
SEP-1999, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
[Previous]
[Next]
NAME:
READ_HOS
PURPOSE:
Read Helios data for synoptic map
CALLING SEQUENCE:
subroutine READ_HOS(cWildCard,nCar,JDCar,XCbeg,ICnr,
& Radius,Speed,Eref,PowV, XElow,XEhigh,iEorW,XRlim,
& iSc,iHOS,cHOS,iSectBeg,iSectEnd,CC,iDay,nDev,dSig,
& NL,XC,YL,ZZ,
& cVel,LngV,LatV,VSol,VSol2,NSIDE)
INPUTS:
cWildCard character*(*) wildcard specification for Helios files
'%%%%%_%%%_####.HOS', where #### is the
position of the rotation number
nCar integer # rotation start times
JDCar(nCar) real*8 rotation start times (Julian days)
XCbeg real Carrington variable
ICnr integer
Radius real reference distance (AU)
Speed real traceback speed (km/s)
Speed .eq. 0: IPS velocities are used for traceback
Speed .ne. 0: traceback at constant speed
Eref real reference elongation used for rescaling intensities
Eref .eq. 0: no rescaling
PowV real (currently effective only if Speed .eq. 0)
output ZZ is multiplied by V^PowV, where
V is the UCSD IPS speed (i.e. allows
calculation of mass flux, etc.)
XElow real minimum elongation limit
XEhigh real maximum elongation limit
iEorW integer -1,0,1 for west only/east+west/east only
XRlim real limit on ecliptic longitude rel. to Sun
iSc integer 1 or 2 for Helios A or B
iHOS integer max. permitted # Helios files to be read
iSectBeg integer modified start sector number
iSectEnd integer modified end sector number
The following three parameters are used by T_FILTER to subtract a
running mean from the time series.
iDay integer time window
nDev integer glitch level (# standard deviations)
dSig real extra fraction of standard deviation added to
running mean
cVel character*(*) wildcard '$IPS:V1234_8.005' for
locating the IPS V-files used for
traceback if Speed=0
OUTPUTS:
iHOS integer actual # Helios files read
cHOS(iHOS) character*(*) names of Helios files
CC integer 1,2,3 for U,B,V
The following three may have been updated by interactive prompts
if the input value of iDay was less than zero (iDay < 0):
iDay integer
nDev integer
dSig real
NL integer # data points
XC real modified Carrington variable Point P after traceback
YL real heliographic latitude
ZZ real intensity (S10) units (scaled to Eref
if Eref .ne. 0; otherwise unscaled)
multiplied by V^PowV, where V is the
UCSD IPS speed.
cVel character*(*) set to IPS velocity file
'$IPS:V1234_8.005'
CALLS: ***
ArrR4Copy, ArrR4TimesConstant, BadR4, ECLIPTIC_HELIOGRAPHIC, GAL_CNTR, HELIOS_1
HELIOS_2, HOSOrbID, HOSRead, Julian, MKVTRACE, SC_ECLIP, SC_ECLIP90, Say, T_FILTER
ThomsonLOSS10Far, ThomsonUBVConst, XMAP_OBS_POS, XMAP_SC_POS, fncWZ, iFltArr
iGetLogical [1], iGetLogical [2], iGridScan, iSearch, itrim, sind
INCLUDE:
include 'hosucsd.h' ! Array size parameters
include 'sun.h'
include 'dirspec.h'
include 'hos_e9.h'
EXTERNAL:
external HELIOS_1
external HELIOS_2
external fncWZ ! not used
PROCEDURE:
MODIFICATION HISTORY:
FEB-1996, Paul Hick (UCSD); extracted from SANHEL.FOR
[Previous]
[Next]
NAME:
ReadG
PURPOSE:
Read data from unedited G*. file or edited E*.DAT file,
containing Cambridge IPS data
CATEGORY:
Data processing
CALLING SEQUENCE:
subroutine ReadG(cDat,nCar,JDCar,MJD,iEdt,Radius,Speed,GPow, iOK,XCmin,XCmax,
& IYRS,DOYS, XDS,XLS,XLL,XDL,XCE,XC,YL,XE,XR,XV,XG,cStr,bMessage)
INPUTS:
cDat character*(*) name of logical for dir containing data
files
nCar integer (read-only
# start times for Carrington rotations
JDCar(nCar) real*8 (read-only)
Carrington start times (Julian days)
MJD integer (read-only)
modified Julian day (JD-2400000.5) for
the requested file
iEdt integer (read-only)
0 = Read unedited data file
1 = Read edited data file
Radius real Reference distance in AU
(not used if Speed=0)
Speed real trace back velocity (km/s)
(if Speed=0 then no traceback is done)
GPow real if non-zero used to scale the measured
G-value: G = G(measured)/RP^GPow
where RP is the heliocentric distance
of the point P.
(i.e. if GPow=0 the unscaled value is
returned)
bMessage logical if .FALSE. suppresses Say call before return
OUTPUTS:
(NTIME=72,NDEC=14)
iOK integer = 0 if file was not opened succesfully
= 1 if file was opened
= 3 if file contained no valid points
XCmin real Minimum XC value (BadR4() if file empty)
XCmax real Maximum XC value (BadR4() if file empty)
IYRS(NTIME,NDEC)integer time: year
DOYS(NTIME,NDEC)real time: doy of year
XDS(NTIME,NDEC) real Earth-Sun distance (AU)
XLS(NTIME,NDEC) real Geocentric ecliptic longitude Sun (degrees)
XLL(NTIME,NDEC) real Difference between geocentric ecliptic longitudes of
line of sight and Sun
XDL(NTIME,NDEC) real Geocentric ecliptic latitude of line of sight
XCE(NTIME,NDEC) real Modified Carrington variable of Earth
XC(NTIME,NDEC) real Modified Carrington variable of 'Point P', except for
an offset of NCoff, i.e. the conventional Carrington
numbers are NCoff+XC(I)
YL(NTIME,NDEC) real Heliographic latitudes (degrees) of 'Point P'
XE(NTIME,NDEC) real Elongation of the line of sight used
If XE<0 the l.o.s. points west of the Sun
If XE>0 the l.o.s. points east of the Sun
XR(NTIME,NDEC) real Right Ascension relative to Sun
XV(NTIME,NDEC) real velocities (currently set to zero)
XG(NTIME,NDEC) real G-factors
Each observation XG refers to a line of sight extending from Earth.
The coordinates XC,YL define the heliocentric position of the point
P along the line of sight closest to the Sun. abs(XE) is the angle
between line of sight and the direction to the center of the solar disk.
cStr character*(*)
CALLS: ***
ArrI4Bad, ArrR4Bad, ArrR4GetMinMax, DATE_DOY, EARTH, ECLIPTIC_EQUATOR
ECLIPTIC_HELIOGRAPHIC, Julian, POINT_ON_LOS, ReadGHD, Say, SunNewcomb, T_GST
XMAP_OBS_POS, XMAP_SC_POS, bOpenFile, cosd, iFilePath, iFreeLun, itrim
CALLED BY:
ReadGIPS
EXTERNAL:
external EARTH
INCLUDE:
include 'openfile.h'
include 'sun.h'
RESTRICTIONS:
> Input files are searched for in the directory assigned to logical $DATA
> Make sure to test iOK before using the output arrays (the arrays are
not always cleared before returning; you may end up using the values
from a previous call to ReadG)
PROCEDURE:
Unedited data files: G12345. where 12345 is the modified Julian day
> The data files contain for each day 72 records (i.e. 72 observation
times, evenly spaced over the whole day) of 14 declinations.
> The original G-factors are coded as hexidecimal numbers. The
translation is done using the Z format specifier
> The final G-factors are calculated from
G = GMAX**(IG/G0-1.)
where GMAX and G0 are constants given in the data file and IG is the
translated hexidecimal number
> Given the UT and the equatorial coordinates (HA=0, declination
specified in data file), the heliocentric coordinates of the point P
are calculated.
> If no G-factor is available for a line of sight the G-factor and
heliocentric coordinates are set to BadR4() (real*4) or BadI4 (int*4)
Edited data files: E12345.DAT where 12345 is the modified Julian day
> Each ASCII file contains 73 records. The first repeats the modified
Julian day number. The other 72 records each contain 14 G-factors
in F8.3 format. The organization is the same as for the unedited files.
MODIFICATION HISTORY:
MAR/APR-1992, Paul Hick (UCSD)
JUL-1993, Paul Hick (UCSD); fixed bug in equatorial-to-ecliptic
coordinate conversion
FEB-1998, Paul Hick (UCSD); added arguments IYRS,..,XCE for support of
IPS deconvolution program.
[Previous]
[Next]
NAME:
ReadGHD
PURPOSE:
Read file header from unedited G*. file or edited E*.DAT file,
containing Cambridge IPS data
CATEGORY:
Data processing
CALLING SEQUENCE:
subroutine ReadGHD(MJD,iU,cFile, bEOH,GMAX,G0)
INPUTS:
MJD integer (read-only)
modified Julian day (JD-2400000.5) for
the requested file
iU integer file logical unit number
cFile character*(*) file name
OUTPUTS:
bEOH logical .TRUE. if header read
.FALSE. if error in header
GMAX,G0 real scaling factors for G values
CALLS: ***
DATE_DOY, Julian, Say, Str2Flt, Str2Flt_Crumbs, itrim
CALLED BY:
ReadG, iReadG
INCLUDE:
include 'sun.h'
PROCEDURE:
Reads header and checks for consistency. Inconsistencies result
in a program abort or return with bEOH=.FALSE.
MODIFICATION HISTORY:
SEP-1992, Paul Hick (UCSD), extracted from READG.FOR
[Previous]
[Next]
NAME:
ReadGIPS
PURPOSE:
Read collection of data from Cambridge daily IPS g-level files
CALLING SEQUENCE:
subroutine ReadGIPS(cDat,nCar,JDCar,
& iEdt,bAuto,bForeCast,
& XCtst1,XCtst2,MJDref,MJDfrst,MJDlast,
& Radius,Speed,Power,
& XElow,XEhigh,iEorW,XRlim,
& NLmax,NL,
& iXP,iYP,iMJD,iYRS,DOYS,XDS,XLS,XLL,XDL,XCE,XE,XC,YL,VV,GG,
& NSmax,iXPsav,iYPsav,iMJDsav,iYRSsav,DOYSsav,XDSsav,XLSsav,
& XLLsav,XDLsav,XCEsav,XEsav,XCsav,YLsav,VVsav,GGsav)
INPUTS:
Arguments passes unmodified to ReadG:
cDat character*(*) name of logical for dir containing data files
nCar integer (read-only)
# start times for Carrington rotations
JDCar(nCar) real*8 (read-only)
Carrington start times (Julian days)
iEdt integer (read-only)
0 = Read unedited data file
1 = Read edited data file
Radius real Reference distance in AU
(not used if Speed=0)
Speed real trace back velocity (km/s)
(if Speed=0 then no traceback is done)
Power real if non-zero used to scale the measured
G-value: G = G(measured)/RP^GPow
where RP is the heliocentric distance
of the point P.
(i.e. if GPow=0 the unscaled value is
returned)
Arguments determining selection of data:
XCtst1,XCtst2
MJDref real*8
MJDfrst,MJDlast integer modified Julian days for earliest, and latest data
files available
XElow,XEhigh real minimum and maximum elongation (degrees)
XEhigh real Only lines of sight with elongation between XElow and XEhigh
are used
iEorW integer = +1: use only lines of sight east of the Sun
= -1: use only lines of sight west of the Sun
= 0: use data east and west of the Sun
XRlim real Only points with Right Ascenscion less than XRlim away
from the Sun are used
Arguments controlling amount of data to be read:
NLmax integer max # data points read into output arrays
NSmax integer max # data points saved in save arrays
NS integer # points in save arrays to be re-used
(usually this will be set by a previous call;
the save arrays can be discarded by setting NS=0;
See PROCEDURE)
OUTPUTS:
NL integer # data points in output arrays
NS integer # data points save in save arrays
iXP (NL) integer location in original daily Cambridge file (hour angle)
iYP (NL) integer location in original daily Cambridge file (declination)
iMJD(NL) integer MJD for original daily Cambridge file
IYRS(NL) integer time: year
DOYS(NL) real time: doy of year
XDS (NL) real Earth-Sun distance (AU)
XLS (NL) real Geocentric ecliptic longitude Sun (degrees)
XLL (NL) real Difference between geocentric ecliptic longitudes of
line of sight and Sun
XDL (NL) real Geocentric ecliptic latitude of line of sight
XCE (NL) real Modified Carrington variable of Earth
XE (NL) real Elongation of the line of sight used
If XE<0 the l.o.s. points west of the Sun
If XE>0 the l.o.s. points east of the Sun
XC (NL) real Modified Carrington variable of 'Point P', except for
an offset of NCoff, i.e. the conventional Carrington
numbers are NCoff+XC(I)
YL (NL) real Heliographic latitudes (degrees) of 'Point P'
XV (NL) real velocities (currently set to zero)
XG (NL) real G-factors
OUTPUT SAVE ARRAYS:
(See PROCEDURE; do not meddle with these arrays !!!!!!!)
IYRSsav(NS) integer time: year
DOYSsav(NS) real time: doy of year
XDSsav(NL) real Earth-Sun distance (AU)
XLSsav(NL) real Geocentric ecliptic longitude Sun (degrees)
XLLsav(NL) real Difference between geocentric ecliptic longitudes of
line of sight and Sun
XDLsav(NL) real Geocentric ecliptic latitude of line of sight
XCEsav(NL) real Modified Carrington variable of Earth
XEsav(NL) real Elongation of the line of sight used
If XE<0 the l.o.s. points west of the Sun
If XE>0 the l.o.s. points east of the Sun
XCsav(NL) real Modified Carrington variable of 'Point P', except for
an offset of NCoff, i.e. the conventional Carrington
numbers are NCoff+XC(I)
YLsav(NL) real Heliographic latitudes (degrees) of 'Point P'
XVsav(NL) real velocities (currently set to zero)
XGsav(NL) real G-factors
CALLS: ***
AskWhat, BadR4, Int2Str, ReadG, Say, itrim
CALLED BY:
ipsd, ipsdt, ipsg2, ipsg2s, ipsg2t
PROCEDURE:
> The save arrays can be used to speed up processing if a new set of data is to be read
for nearly the same input specifications as the previous call: most of the required
data will be extracted from the save arrays, rather than reading them from file.
> If the save arrays are to be used set NSmax ~ NLmax.
> If the save arrays are not be used at all, set NS=0. In that case the save arrays
are not accessed at all, and some memory can be saved by setting NSmax=1, and declaring
the save arrays are scalars in the calling program.
MODIFICATION HISTORY:
JUN-1992, Paul Hick (UCSD)
MAR-1998, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
merged synoptic map version with version for the deconvolution program.
[Previous]
[Next]
NAME:
ReadVIPS
PURPOSE:
Reads IPS velocity data from yearly data files into arrays
CATEGORY:
I/O
CALLING SEQUENCE:
subroutine ReadVIPS(iReadVIPS,iProcessVIPS,cWildVIPS,
& nCar,JDCar,bAuto,XCtst1,XCtst2,NCoff,MJDref,
& Radius, XElow,XEhigh,iEorW,XRlim,
& NLmax,NL,
& IYRF,IREC,IYRS,DOYS,XDS,XLS,XLL,XDL,XCE,XE,XC,YL,VV,GG,
& NSmax,IYRFsav,IRECsav,IYRSsav,DOYSsav,XDSsav,XLSsav,XLLsav,
& XDLsav,XCEsav,XEsav,XCsav,YLsav,VVsav,GGsav)
INPUTS:
iReadVIPS external integer function
iProcessVIPS external integer function
external functions controlling data file access
cWildVIPS character*(*) wildcard used to locate data files;
the wildcard must contain the substring
'%%'
nCar integer dimension of JDCar
JDCar(nCar) integer start times (Julian days) of Carrington rotations
bAuto logical
XCtst1 real modified Carrington variable for start of search
XCtst2 real modified Carrington variable for end of search
NCoff integer JDCar(I) is the start of rotation NCoff+I
MJDref double precision if not equal 0, only data prior to
modified Julian day MJDref are used
Radius real reference distance (AU)
XElow real lower limit on elongation from Sun
XEhigh real upper limit on elongation from Sun
iEorW integer 0: Both east and west data
1: East data only
-1: West data only
XRlim real limit on difference RA of point-P and
RA of Sun.
NLmax integer max. # points read into arrays
XC,YL,VV,GG, XCsav,YLsav,VVsav,GGsav
NSmax integer
OUTPUTS:
NL integer # valid data points in arrays XC,YL,VV,GG
IYRF(NLmax) integer year of file from which observation was extracted (should be same as IYRS)
IREC(NLmax) integer record number on file IYRF
IYRS(NLmax) integer time of observation: year
DOYS(NLmax) real time of observation: day of year (incl. fraction for time of day)
XDS (NLmax) real Sun-Earth distance
XLS (NLmax) real geocentric ecliptic longitude Sun
XLL (NLmax) real geocentric ecliptic lng(P)-lng(Sun) (deg)
XDL (NLmax) real geocentric ecliptic lat(P) (deg)
XCE (NLmax) real modified Carrington variable of sub-Earth point on Sun
XE (NLmax) real elongation (deg) (>0: East of Sun; <0: West of Sun)
XC (NLmax) real modified Carrington variable point P after traceback to
heliocentric distance Radius at speed VV
YL (NLmax) real heliographic latitude point P
VV (NLmax) real IPS velocity (km/s)
GG (NLmax) real IPS disturbance factor
NSmax integer # data points saved in XCsav,YLsav,VVsav
IYRFsav(NSmax) integer scratch arrays (used internally only)
IRECsav(NSmax) integer
IYRSsav(NSmax) integer
DOYSsav(NSmax) real
XDSsav (NSmax) real
XLLsav (NSmax) real
XDLsav (NSmax) real
XCEsav (NSmax) real
XEsav (NSmax) real
XCsav (NSmax) real
YLsav (NSmax) real
VVsav (NSmax) real
GGsav (NSmax) real
CALLED BY:
ipsd, ipsg2, ipsg2s, ipsg2t
RESTRICTIONS:
Data files are read using a logical unit number assigned by iGetLun.
Since a data file may be left open on return, there is a potential
danger if the same unit is used somewhere. Assign unit numbers
with iGetLun to make sure this does not happen.
CALLS: ***
FLINT8, Flt2Str, Int2Str, Julian, Say, Str2Flt, Str2Str, bLOSCheckLoc, bOpenFile
cHideLogical, iFreeLun, iGetFileSpec, iSearch, iSetFileSpec
INCLUDE:
include 'dirspec.h'
include 'filparts.h'
include 'openfile.h'
PROCEDURE:
> All points in the range [XCtst1,XCtst2] are extracted from the data files
>!!!! The modified Carrington variables are in units offset by NCoff from
the regular Carrington rotation number (i.e. in units which can be
used as index to JDCar)
> Two external user-defined are needed to read the data files.
External functions exist for reading the Nagoya and the UCSD velocity
IPS data: iReadNagoya, iProcessNagoya
iReadUCSD , iProcessUCSD
iReadOoty , iProcessOoty
These are programmed in the form:
function iReadNagoya(iU,iFirst)
... ( read a record from the data file ) ...
return
entry iProcessNagoya(iRec,nCar,JDCar,NCoff,Radius,
nYr,Doy,XCsc,XCobs,xLat,xVV,xGG,dRA,
rLngSun,rLngP,rLatP,rEloP )
... ( process the record to produce the output values ...
... nYr,Doy,XCsc,XCobs,xLat,xVV,xGG,dRA, ...
... rLngSun,rLngP,rLatP,rEloP )
return
end
Input values to iReadVIPS
iU integer logical unit number assigned by bOpenFile
iFirst integer 1 : initializes record counter
(used when reading 1st record of file)
0 : adds one to record counter
nCar integer # of Carrington rotation start times
JDCar double precision Start times of Carrington rotation in
modified Julian days. The first entry
JDCar(1) is for rotation NCoff
NCoff integer Carrington rotation offset
XCend real maximum permitted Carrington variable.
When Earth moves passed XCend then all
data are assumed collected.
Radius real reference distance (AU)
Output values of iProcessVIPS:
iProcessVIPS 0: bad IPS observation
1: good IPS observation
2: all data collected (Earth passed XCend)
iRec integer record # on file
nYr integer year and ..
Doy real .. day of year of observation
XCsc real modified Carington variable for sub-SC point
(NCoff already subtracted)
XCobs real modified Carrington variable of point P after
traceback to distance Radius
(NCoff already subtracted)
xLat real heliographic latitude point P (deg)
xVV real IPS velocity (km/s)
xGG real IPS disturbance factor
dRA real RA(point P)-RA(Sun) (deg)
rLngSun real geocentric ecliptic longitude Sun (deg)
rLngP real geocentric ecliptic longitude of point P (deg)
(relative to Sun)
rLatP real geocentric ecliptic latitude of point P (deg)
rEloP real geocentric source elongation (deg)
The sign is used to indicate East/West of Sun
rEloP>0: East of Sun; rEloP<0: West of Sun
MODIFICATION HISTORY:
JUN-1994, Paul Hick (UCSD/CASS)
OCT-1996, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
Added Ooty routines
[Previous]
[Next]
NAME:
ReadVIPSCheckData
CALLING SEQUENCE:
entry ReadVIPSCheckData(bV, bG, Vmin,Vmax,Gmin,Gmax)
INPUTS:
bV logical
bG logical
CALLED BY:
iProcessNagoya, iReadNagoya
SEE ALSO:
ReadVIPSValidData
[Previous]
[Next]
NAME:
ReadVIPSLOSCheck
PURPOSE:
CALLING SEQUENCE:
entry ReadVIPSLOSCheck(XCbegIn,XCendIn,NLOSIn,NINSIDEIn,DLOSIn)
INPUTS:
XCbegIn real modified Carrington variable for start of map
XCendIn real modified Carrington variable for end of map
NLOSIn integer # segments along line of sight
If NLOSIn=0 then bLOSCheckLoc always returns
.TRUE., i.e. all lines of sight are accepted.
NINSIDEIn integer when at least NINSIDEIn segments lie inside
[XCbegIn, XCendIn]
the return value of bLOSCheckLoc is .TRUE.
DLOSIn real # step size along line of sight
(what units?)
CALLS: ***
FLINT8, Flt2Str, Int2Str, Julian, Say, Str2Flt, Str2Str, bLOSCheckLoc, bOpenFile
cHideLogical, iFreeLun, iGetFileSpec, iSearch, iSetFileSpec
SEE ALSO:
ReadVIPS, bLOSCheckLoc
PROCEDURE:
Input values are copied to internally-saved variables
(XCbeg,XCend,NLOS,NINSIDE,DLOS) for
use by ReadVIPS, which in turn passes them to bLOSCheckLoc.
NLOS is initialized to zero. This forces bLOSCheckLoc to
return .TRUE., i.e. to accept all lines of sight.
MODIFICATION HISTORY:
[Previous]
[Next]
NAME:
ReadVIPSLOSCheckn
PURPOSE:
CALLING SEQUENCE:
entry ReadVipsLOSCheckn(XCbegIn,XCendIn,NLOSIn,NINSIDEIn,DLOSIn)
INPUTS:
XCbegIn real modified Carrington variable for start of map
XCendIn real modified Carrington variable for end of map
NLOSIn integer
NINSIDEIn integer
DLOSIn real
CALLS: ***
FLINT8, Flt2Str, Int2Str, Julian, Say, Str2Flt, Str2Str, bLOSCheckLoc, bOpenFile
cHideLogical, iFreeLun, iGetFileSpec, iSearch, iSetFileSpec
SEE ALSO:
ReadVIPS
PROCEDURE:
Input values are copied to internally saved variable for use by ReadVIPS
MODIFICATION HISTORY:
[Previous]
[Next]
NAME:
ReadVIPSn
PURPOSE:
Reads IPS velocity data from yearly data files into arrays
CATEGORY:
I/O
CALLING SEQUENCE:
subroutine ReadVIPSn(iReadVIPS,iProcessVIPS,cWildVIPS,
& nCar,JDCar,bAuto,XCtst1,XCtst2,NCoff,MJDref,
& Radius, XElow,XEhigh,iEorW,XRlim,
& NLmax,NL,SRC,SRCsav,
& IYRF,IREC,IYRS,DOYS,XDS,XLS,XLL,XDL,XCE,XE,XC,YL,VV,GG,
& NSmax,IYRFsav,IRECsav,IYRSsav,DOYSsav,XDSsav,XLSsav,XLLsav,
& XDLsav,XCEsav,XEsav,XCsav,YLsav,VVsav,GGsav)
INPUTS:
iReadVIPS external integer function
iProcessVIPS external integer function
external functions controlling data file access
cWildVIPS character*(*) wildcard used to locate data files;
the wildcard must contain the substring
'%%'
nCar integer dimension of JDCar
JDCar(nCar) integer start times (Julian days) of Carrington rotations
bAuto logical
XCtst1 real modified Carrington variable for start of search
XCtst2 real modified Carrington variable for end of search
NCoff integer JDCar(I) is the start of rotation NCoff+I
MJDref double precision if not equal 0, only data prior to
modified Julian day MJDref are used
Radius real reference distance (AU)
XElow real lower limit on elongation from Sun
XEhigh real upper limit on elongation from Sun
iEorW integer 0: Both east and west data
1: East data only
-1: West data only
XRlim real limit on difference RA of point-P and
RA of Sun.
NLmax integer max. # points read into arrays
XC,YL,VV,GG, XCsav,YLsav,VVsav,GGsav
NSmax integer
OUTPUTS:
NL integer # valid data points in arrays XC,YL,VV,GG
SRC (NLmax) character*9 Character Source identifier
IYRF(NLmax) integer year of file from which observation was extracted (should be same as IYRS)
IREC(NLmax) integer record number on file IYRF
IYRS(NLmax) integer time of observation: year
DOYS(NLmax) real time of observation: day of year (incl. fraction for time of day)
XDS (NLmax) real Sun-Earth distance
XLS (NLmax) real geocentric ecliptic longitude Sun
XLL (NLmax) real geocentric ecliptic lng(P)-lng(Sun) (deg)
XDL (NLmax) real geocentric ecliptic lat(P) (deg)
XCE (NLmax) real modified Carrington variable of sub-Earth point on Sun
XE (NLmax) real elongation (deg) (>0: East of Sun; <0: West of Sun)
XC (NLmax) real modified Carrington variable point P after traceback to
heliocentric distance Radius at speed VV
YL (NLmax) real heliographic latitude point P
VV (NLmax) real IPS velocity (km/s)
GG (NLmax) real IPS disturbance factor
NSmax integer # data points saved in XCsav,YLsav,VVsav
SRCsav (NSmax) character*9
IYRFsav(NSmax) integer scratch arrays (used internally only)
IRECsav(NSmax) integer
IYRSsav(NSmax) integer
DOYSsav(NSmax) real
XDSsav (NSmax) real
XLLsav (NSmax) real
XDLsav (NSmax) real
XCEsav (NSmax) real
XEsav (NSmax) real
XCsav (NSmax) real
YLsav (NSmax) real
VVsav (NSmax) real
GGsav (NSmax) real
CALLED BY:
ipsdt
RESTRICTIONS:
Data files are read using a logical unit number assigned by iGetLun.
Since a data file may be left open on return, there is a potential
danger if the same unit is used somewhere. Assign unit numbers
with iGetLun to make sure this does not happen.
CALLS: ***
FLINT8, Flt2Str, Int2Str, Julian, Say, Str2Flt, Str2Str, bLOSCheckLoc, bOpenFile
cHideLogical, iFreeLun, iGetFileSpec, iSearch, iSetFileSpec
INCLUDE:
include 'dirspec.h'
include 'filparts.h'
include 'openfile.h'
PROCEDURE:
> All points in the range [XCtst1,XCtst2] are extracted from the data files
>!!!! The modified Carrington variables are in units offset by NCoff from
the regular Carrington rotation number (i.e. in units which can be
used as index to JDCar)
> Two external user-defined are needed to read the data files.
External functions exist for reading the Nagoya and the UCSD velocity
IPS data: iReadNagoya, iProcessNagoya
iReadUCSD , iProcessUCSD
iReadOoty , iProcessOoty
These are programmed in the form:
function iReadNagoya(iU,iFirst)
... ( read a record from the data file ) ...
return
entry iProcessNagoya(iRec,nCar,JDCar,NCoff,Radius,
cSrc,nYr,Doy,XCsc,XCobs,xLat,xVV,xGG,dRA,
rLngSun,rLngP,rLatP,rEloP )
... ( process the record to produce the output values ...
... nYr,Doy,XCsc,XCobs,xLat,xVV,xGG,dRA, ...
... rLngSun,rLngP,rLatP,rEloP )
return
end
Input values to iReadVIPS
iU integer logical unit number assigned by bOpenFile
iFirst integer 1 : initializes record counter
(used when reading 1st record of file)
0 : adds one to record counter
nCar integer # of Carrington rotation start times
JDCar double precision Start times of Carrington rotation in
modified Julian days. The first entry
JDCar(1) is for rotation NCoff
NCoff integer Carrington rotation offset
XCend real maximum permitted Carrington variable.
When Earth moves passed XCend then all
data are assumed collected.
Radius real reference distance (AU)
Output values of iProcessVIPS:
iProcessVIPS 0: bad IPS observation
1: good IPS observation
2: all data collected (Earth passed XCend)
iRec integer record # on file
cSrc character Source name
nYr integer year and ..
Doy real .. day of year of observation
XCsc real modified Carington variable for sub-SC point
(NCoff already subtracted)
XCobs real modified Carrington variable of point P after
trace-back to distance Radius
(NCoff already subtracted)
xLat real heliographic latitude point P (deg)
xVV real IPS velocity (km/s)
xGG real IPS disturbance factor
dRA real RA(point P)-RA(Sun) (deg)
rLngSun real geocentric ecliptic longitude Sun (deg)
rLngP real geocentric ecliptic longitude of point P (deg)
(relative to Sun)
rLatP real geocentric ecliptic latitude of point P (deg)
rEloP real geocentric source elongation (deg)
The sign is used to indicate East/West of Sun
rEloP>0: East of Sun; rEloP<0: West of Sun
MODIFICATION HISTORY:
JUN-1994, Paul Hick (UCSD/CASS)
OCT-1996, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
Added Ooty routines
[Previous]
[Next]
NAME:
ReadVIPSValidData
PURPOSE:
Decide how ReadVIPS checks for bad data
CATEGORY:
Aux
CALLING SEQUENCE:
subroutine ReadVIPSValidData(iCheck,Vmin,Vmax,Gmin,Gmax)
INPUTS:
iCheck integer =LOS__CHECKV: reject only observations with V <= 0
=LOS__CHECKG: reject only observations with G = 0
=LOS__CHECKV+LOS__CHECKG: reject observations with G = 0 and V <= 0
OUTPUTS:
(none)
CALLED BY:
ipsd, ipsg2, ipsg2s, ipsg2t
INCLUDE:
include 't3d_index.h'
PROCEDURE:
ReadVIPSValidData is called prior to calling ReadVIPS, and sets to
logicals defining which G and V data are rejected. The logical values
are stored internally, and can be retrieved using ReadVIPSCheckData.
If ReadVIPSValidData is not called then only data with V<=0 are rejected.
SEE ALSO:
ReadVIPSCheckData
MODIFICATION HISTORY:
JUN-1994, Paul Hick (UCSD)
[Previous]
[Next]
NAME:
RebinSphere
PURPOSE:
(NOT WORKING YET)
Fills 'holes' and/or smooths a 3D array using a Gaussian weighting function.
Two of the array dimensions represent a regular grid in spherical
coordinates (longitude and latitude). The third represents a regular
grid in radial distance.
CALLING SEQUENCE:
subroutine RebinSphere(dXC,nLng,nLat,nR,Z,WidDeg,R1,iBadZ,WThreshold,ClipLng, mLng,mLat,mR,ZZ)
INPUTS:
dXC real range of Carrington variable covered by nLng
i.e. number of 360 deg rotations.
nLng integer # longitudes
nLat integer # latitudes
nR integer # radial distances
Z(nLng,nLat,nR) real 3D array of function values
WidDeg real Width of Gaussian used for angular
smoothing (in degrees) (WidDeg<0 has
special meaning; see PROCEDURE)
R1 real (3D version only)
R1 > 0:Radial distance for inner boundary (in
grid spacings), i.e. location of Z(*,*,1)
R1=0 IS INVALID; MUST BE R1>0
R1 < 0:(value does not matter)
suppresses the radial smoothing, i.e.
each subarray Z(*,*,i),i=1,nR is
2D smoothed over longitude and latitude only.
iBadZ integer 0: Invalid elements remain invalid;
valid elements are replaced by a
smoothed value
1: All elements (valid and invalid) are
replaced by smoothed values.
2: Invalid elements are replaced by
smoothed values; valid elements remain
untouched.
The following two options are useful if all
bad bins have to be filled in with something.
Use them at your own risk (see PROCEDURE).
3: Same as iBadZ=1, but if any invalid
elements remain at the end, these are
all filled in by a call to GridFill
4: Same as iBadZ=2, but if any invalid
elements remain at the end, these are
all filled in by a call to GridFill
>=10: Use open grid for longitude and latitude (?)
>=100: Use lookup table for Gaussian
WThreshold real The replacement by a smoothed value is
made only if total weight is
larger than/equal to the threshold value.
(see PROCEDURE).
ClipLng real Longitude difference (see PROCEDURE)
(usually set to zero).
OUTPUTS:
Z(nLng,nLat,nR) real smoothed array of function values
INCLUDE:
include 'math.h'
CALLS: ***
ArrR4Copy, BadR4, GaussLookup, GridFill, Say, iArrR4ValuePresent
RESTRICTIONS:
> GridSphere3D uses internal scratch arrays, which are
dimensioned using 3 parameters, LNG,LAT and LNR. If the scratch
arrays are too small, program execution stops.
> iBadZ=3 and iBadZ=4:
GridFill uses a 2D algorithm to fill in holes. If nR>1 then GridFill
is applied to each level k=1,nR separately.
PROCEDURE:
> Invalid or 'Bad' array elements are indicated by the value BadR4()
> The 1st dimension represents a regular grid in longitude covering
[0,360] degrees, i.e. Lng(i) = 360*(i-1)/(nLng-1), i=1,nLng.
The 2nd dimension represents a regular grid in latitude covering
[-90,+90] degrees, i.e. Lat(j) = -90*[-1+2*(j-1)/(nLat-1)], j=1,nLat.
The 3rd dimension represents a regular grid in radial distance,
i.e. R(k) = R1+k-1
> Obviously, 2D arrays can be smoothed by setting nR=1.
> GridSphere2D is just a special call to GridSphere3D with R1=-1 (the
value does not matter as long as it's negative).
> The weighting is Gaussian with weight=1 at the origin. To avoid loosing
valid elements for iBadZ=0 or 1, set the threshold weight to a
value less than 1.
> The angular weighting factor involves the angular distance between
two locations on a sphere. The points are connected by two arcs,
one is the minimum angular distance A (0<A<180), the other is the
complementary angle AC=360-A (180<AC<360).
If ClipLng=0 the angle A is always used. As a result, the smoothed
function value for small/large longitudes will depend on the input
function values at large/small longitudes with fairly large weighting
factors (since the angular distance is small).
This effect can be suppressed by setting ClipLng to a non-zero value.
If the longitude difference abs(Lng(i1)-Lng(i2)) is larger than
ClipLng, then the corresponding element is excluded.
BE CAREFUL WHEN USING THIS OPTION. In particular, setting
ClipLng to values around 180 degrees affects the smoothing for
points near the poles (where points with a wide range of longitude
differences are close together). As a guideline
ClipLng > 180+3*WidDeg is probably not a bad place to start.
> If WidDeg > 0, the smoothing procedure is speeded up by looping
over only part of the array when calculating the smoothed function
value. Excluded are all elements which are more than 3 times the
Gaussian width away from the element for which the smoothed value is
calculated (the weight would be less than exp(-9)). The exclusion
is based on an approximate calculation of the distance between points.
Near the poles there may be a problem (see the explanation in the code),
but I think it's under control now.
In case you don't trust the result set WidDeg to a negative value.
If WidDeg <0, then the absolute value is used as Gaussian width, and
the whole array is used in the calculation of the smoothed average.
The procedure will be a LOT slower though.
> If ClipLng=0 then the averaging algorithm is mod(XCend-XCbeg), i.e. if
in the input array column 1 (XC = XCend) and column nLng (XC = XCbeg)
are the same this is also true for the output array.
HOWEVER this symmetry is broken if iBadZ=3 or 4 because of the extra
call to GridFill.
MODIFICATION HISTORY:
FEB-1997, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
[Previous]
[Next]
NAME:
RemoveTag
PURPOSE:
Remove a tag (substring) from a list of tags
CATEGORY:
Strings: tag manipulation
CALLING SEQUENCE:
subroutine RemoveTag(cTags,cSep,cTag)
INPUTS:
cTags character*(*) list of tags, separated by the cSep character
cSep character character used as separater (usually comma)
cTag character*(*) tag (substring) to be removed
OUTPUTS:
cTags character*(*) updated list of tags
CALLS: ***
LocateTag, itrim
CALLED BY:
TheFit
SEE ALSO:
ReplaceTag, SwitchTag
PROCEDURE:
MODIFICATION HISTORY:
NOV-1994, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
JUN-1995, Paul Hick (UCSD; pphick@ucsd.edu), added SwitchTag
[Previous]
[Next]
NAME:
ReplaceTag
PURPOSE:
Replace a tag (substring) in a list of tags by another tag
CATEGORY:
Strings: tag manipulation
CALLING SEQUENCE:
subroutine ReplaceTag(cTags,cSep,cOldTag,cNewTag)
INPUTS:
cTags character*(*) list of tags, separated by the cSep character
cSep character character used as separater (usually comma)
cOldTag character*(*) tag (substring) to be replaced
cNewTag character*(*) tag inserted at location of old tag
OUTPUTS:
cTags character*(*) updated list of tags (RemoveTag, SwitchTag only)
CALLS: ***
LocateTag, itrim
CALLED BY:
SwitchTag
SEE ALSO:
RemoveTag, SwitchTag
PROCEDURE:
MODIFICATION HISTORY:
NOV-1994, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
JUN-1995, Paul Hick (UCSD; pphick@ucsd.edu), added SwitchTag
[Previous]
[Next]
NAME:
rice
PURPOSE:
Compress/decompress *.nic files
CATEGORY:
I/O
CALLING SEQUENCE:
program rice
rice file1 [file2 ...] [/directory[=directory]]
rice /help (displays help)
(on Linux use a '-' instead of '/')
INPUTS:
file1 file2 file specifications for files to be processed. Only
files with type .nic or .ice are accepted. The file
name can contain wildcards. Directories are optional.
If no files are specified then the user is prompted for
a single file specification
/directory=directory
output directory for compressed/decompressed files
Specifying /directory (without an '=directory') will
put output files in the same directory as the input
files.
If no directory is specified then the user is prompted
to specify a directory. The default directory presented
will be the directory of the first input file.
CALLS: ***
AskChar, ForeignArg, Int2Str, LocFirst, LocFirstLen, Say, Str2Str, bCompressNic
bUncompressNic, cInt2Str, iCheckDirectory, iGetFileSpec, iSearch, iSetFileSpec
lowercase
INCLUDE:
include 'dirspec.h'
include 'openfile.h'
include 'filparts.h'
RESTRICTIONS:
This program is only intended to compress/decompress *.nic files from
the SMEI camera. If a *.ice file is decompressed which is not a
compressed *.nic file then the decompressed file will contain garbage.
PROCEDURE:
> On NT this program will usually be executed by clicking on the program
icon, i.e. without any command line arguments. When prompted for
File(s) to be processed
specify a file name and type (the directory is optional).
The name may include a wild card; the type must be .nic or .ice
> In NT it is possible to select up to 100 files, and 'drag and drop' them
on the program icon (the value 100 is defined as a parameter nVar=100)
> When prompted for
Output directory
specify a destination directory for the output files. The default
(selected by hitting return) is the same directory as the input file(s).
> .nic files are compressed to .ice files
> .ice files are decompressed to .nic files.
> Files implied by the file1, file2, etc. arguments are accumulated in
an array of file names. Currently a maximum of 2000 files are processed.
MODIFICATION HISTORY:
DEC-2000, Kevin Nguyen, Paul Hick (UCSD; pphick@ucsd.edu)
[Previous]
[Next]
NAME:
rotate
PURPOSE:
Calculate polar angles in rotated coordinate system
CATEGORY:
Math: coordinate transformation
CALLING SEQUENCE:
subroutine rotate(ALFA,BETA,GAMMA,PHI,RLAT)
INPUTS:
ALFA real phase angle of the pole Z(new) in old coordinate system
BETA real polar angle of the pole Z(new) in old coordinate system
GAMMA real phase angle of X(new) in coordinate system (2)
PHI real phase angle in old coordinate system
RLAT real latitude in old coordinate system (-90<=RLAT<=90)
OUTPUTS:
PHI real phase angle in new coordinate system (0<=PHI<360)
RLAT real latitude in new coordinate system
CALLS: ***
Say, dacosd, datan2d, dcosd, dsind
CALLED BY:
ECLIPTIC_EQUATOR, ECLIPTIC_HELIOGRAPHIC, ECLIPTIC_HELIOGRAPHIC8, KeplerOrbit
PRECESSION_ROT
PROCEDURE:
Given phase and polar angles of a point in some coordinate system
[axes: X(old),Y(old),Z(old)], phase and polar angles are calculated in
the new coordinate system [axes: X(new),Y(new),Z(new)] rotated with
respect to the original one over the Euler angles ALFA, BETA, GAMMA.
The rotation from old to new system is realized by
(1) rotation around Z(old) over ALFA ---> X(1),Y(1),Z(1)=Z(old)
(2) rotation around Y(1) over BETA ---> X(2),Y(2)=Y(1),Z(2)=Z(new)
(3) rotation around Z(new) over GAMMA ---> X(new),Y(new),Z(new).
All angles are in degrees.
MODIFICATION HISTORY:
1989, Paul Hick (MPAE,UCSD/CASS; pphick@ucsd.edu)
[Previous]
[Next]
NAME:
rotate_dcm2quat
PURPOSE:
Convert direction cosine matrix to quaternion
CATEGORY:
gen/for/lib
CALLING SEQUENCE:
subroutine rotate_dcm2quat(dcm,qq)
INPUTS:
dcm(3,3) double precision direction cosine matrix
OUTPUTS:
q(4) double precision quaternion
CALLED BY:
Time2smei_quaternion
PROCEDURE:
MODIFICATION HISTORY:
JUL-2006, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
[Previous]
[Next]
NAME:
rotate_euler2dcm
PURPOSE:
Convert Euler angles to direction cosine matrix
CATEGORY:
gen/for/lib
CALLING SEQUENCE:
subroutine rotate_euler2dcm(alfa,beta,gamma,dcm)
INPUTS:
alfa double precision rotation around z-axis
beta double precision rotation around y-axis
gamma double precision rotation arounc z-axis
Euler angles
OUTPUTS:
dcm(3,3) double precision direction cosine matrix
CALLS: ***
dcosd, dsind
CALLED BY:
Time2smei_quaternion
PROCEDURE:
MODIFICATION HISTORY:
JUL-2006, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
[Previous]
[Next]
NAME:
rotated
PURPOSE:
Calculate polar angles in rotated coordinate system
CATEGORY:
Math: coordinate transformation
CALLING SEQUENCE:
subroutine rotated(ALFA,BETA,GAMMA,PHI,RLAT)
INPUTS:
ALFA double precision phase angle of the pole Z(new) in old coordinate system
BETA double precision polar angle of the pole Z(new) in old coordinate system
GAMMA double precision phase angle of X(new) in coordinate system (2)
PHI double precision phase angle in old coordinate system
RLAT double precision latitude in old coordinate system (-90<=RLAT<=90)
OUTPUTS:
PHI double precision phase angle in new coordinate system (0<=PHI<360)
RLAT double precision latitude in new coordinate system
CALLS: ***
Say, dacosd, datan2d, dcosd, dsind
CALLED BY:
Time2EclipticEquatorial, Time2EclipticHeliographic, Time2KeplerOrbit
Time2Precession
PROCEDURE:
Given phase and polar angles of a point in some coordinate system
[axes: X(old),Y(old),Z(old)], phase and polar angles are calculated in
the new coordinate system [axes: X(new),Y(new),Z(new)] rotated with
respect to the original one over the Euler angles ALFA, BETA, GAMMA.
The rotation from old to new system is realized by
(1) rotation around Z(old) over ALFA ---> X(1),Y(1),Z(1)=Z(old)
(2) rotation around Y(1) over BETA ---> X(2),Y(2)=Y(1),Z(2)=Z(new)
(3) rotation around Z(new) over GAMMA ---> X(new),Y(new),Z(new).
All angles are in degrees.
MODIFICATION HISTORY:
JAN-2004, Paul Hick (UCSD/CASS; pphick@ucsd.edu)