[Previous]
[Next]
NAME:
Say
PURPOSE:
Print informational or error messages in a format modeled after the VMS/DCL messages.
CALLING SEQUENCE:
subroutine Say(cP2,cP3,cP4,cP5)
call Say(cName,cSeverity,cMessageID,cMessage)
INPUTS:
(all are read-only)
cName character*(*) program name
cSeverity character*(*) W,S,E,I,D,w,s,e,i,d
cMessageID character*(*) descriptor of error message
if cMessageID(1:4)='Stop' program will terminate
if cMessageID='<time>' then the message ID will be
current system time
if cMessageID='<fmt>' with 'fmt' a valid time format
(see Time2Str) then the message ID is the
system time displayed in the specified format,
e.g. '<hh:mm:ss>' displays the time of day.
cMessage character*(*) full message string; the separator # can be
used to output lines over multiple lines.
Only cMessage sections of non-zero length are printed
LIB__SIGNAL_QUIET global symbol (not case-sensitive)
string containing one or more of the severity status chars
WSEIF. The error message is suppressed if the current severity
is present in the LIB_SIGNAL_QUIET list.
LIB__SIGNAL_STOP global symbol (not case-sensitive)
string containing one or more of the severity status chars
WSEIF. Error messages of this type will result in program termination.
Severity E and F ALWAYS result in program termination.
For individual messages program termination can be forced by setting
the first 4 characters of cMessageID(1:4)='Stop' (case sensitive!!)
LIB__SIGNAL_FILE global symbol
if set to 1 then messages are written to a file instead of
standard output. The file name is 'say.txt' and is located in
the directory cTemp (see include file dirspec.h)
OUTPUTS:
Single message to SYS$OUTPUT or to file.
Program termination is done by OSExitCmd. The error code passed to
OSExitCmd is 0=W,1=S,2=E,3=I,4=F. (On VMS the 'Inhibit display' bit is also set).
CALLED BY:
ArrayLoc3, AskLimit, Average, BField_Choose, BField_Get, BListAll, BList_NSO_NOAA
BList_WSO_NOAA, BRead_WSO, BuildSourceSurface, CheckMass, Connect
DailyIPS_UCSD [1], DailyIPS_UCSD [2], Dust, ExpandSW, Extractd, Extractd3d
FileSelection, FixModel, FixModeltdn, ForeignArg, ForeignArgFind, GIPSCAST, GIPSIMP
GridFill, GridRan2Reg, GridSphere3D, GridSphereRange, GridSphereWeight, HERDISK
HOSInquire, HOSOrbID, HOSPlot, HOSRead, HOSRunningMean, HOSUpdate, HOSWrite
HOSdos2vms, IPSConstraints, LOSClean, LOSReach, LOSSanityCheck, LOSTweak, LOSWeights
MAP_TZERO, MKVTRACE, MapReadSingle, MapReadTimes, MessengerOrbit, MkDMap, MkDMaptdn
MkShiftdn, MkVMap, MkVMaptdN, NODAT, NicHdr, OGetRecord, Pandora, Pandora_Menu
Pandora_Records, Peep, READ_HOS, ReadG, ReadGHD, ReadGIPS, ReadVIPS, ReadVIPSLOSCheck
ReadVIPSLOSCheckn, ReadVIPSn, RebinSphere, SC_ECLIP, SC_ECLIP90, SD, SD_SCAN, SD_TREE
SW_Model_Kinematic, SetGipsy, SetGrid, SetLog2Dir, SetRotations, SortIPS
SphereWeight, SplineGridX, SplineGridY, SplineX, SplineY, StereoAOrbit, StereoBOrbit
Str2Dbl, Str2Flt, Str2Flt_Exp, Str2Flt_FforI, Str2Flt_Int, Str2Flt_Mask
Str2Flt_XforA, Str2Int, T3D_Read_B, T3D_marker, T3D_show, T_FILTER, TheFit
Time2Carrington, Time2CarringtonT0, Time2Split, Time2smei_eph, UlyssesOrbit
WR2DARR, Write3D_bb_XC, Write3D_bbtt, XMAP_SC_POS, XMAP_SC_POS8, bOpenFile, bReadNic
bTempFile, dailyips [1], dailyips [2], iFltArr, iHOSArch, iHOSInfo, iHOSRead
iHOSWrite, iOpenFile, iSearch, iSetDefaultDir, ice_read, ice_write, ipsd, ipsdt, ipsg2
ipsg2s, ipsg2t, jpl_close, jpl_init, jpl_message, jpl_state, libarg, mkenv, nrPolInt
nrPolInt2, nrQRomb, nrQRomo, nrQSimp, nrQTrap, nrRatInt, nrSplInt, nrSpline, nrSpline2
nrTrapZD, nrZBrent, nrZBrentd, rice, rotate, rotated, say_fts, smei_base, smei_cal
smei_cal_add, smei_cal_bin, smei_cal_build, smei_cal_c3mask, smei_cal_get
smei_cal_group, smei_cal_init, smei_cal_read, smei_cal_write, smei_eclipse
smei_foreign, smei_frm_base, smei_frm_c3fudge, smei_frm_fts_eph, smei_frm_ok
smei_frm_path, smei_frm_ped, smei_frm_ped_guess, smei_frm_ratio, smei_frm_read
smei_frm_read_get_sdark, smei_frm_write, smei_get_glare, smei_get_starmask
smei_orb, smei_orb_cal_name, smei_orb_camera, smei_orb_get, smei_orb_min_name
smei_orb_min_number, smei_orb_name, smei_orb_number, smei_orb_read
smei_orb_time, smei_orb_version, smei_orb_write, smei_orbit2, smei_orbit_info2
smei_orbit_period2, smei_orbit_time2, smei_sky_iread, smei_sky_read, smei_skyd
smei_skyd_combine, smei_skyd_fill, smei_skyd_flush, smei_skyd_fts, smei_skyd_go
smei_skyd_init, smei_skyd_make, smei_skyd_pixel, smei_skyd_scan, smei_skyd_size
smei_skyd_sky, smei_skyd_sort, sprint, timer
INCLUDE:
include 'dirspec.h'
include 'filparts.h'
CALLS: ***
LocFirstLen, OSExitCmd, cTime2System, iFilePath, iFreeAllLun, iFreeLun, iGetLun
iGetSymbol [1], iGetSymbol [2], iHideLogical, itrim, uppercase
RESTRICTIONS:
The severity string should be only one character long
PROCEDURE:
> Use Say0 in graphics program (VMS)
> If the severity is E (error) or F (fatal) program execution stops. The
symbol $STATUS is set to a FALSE (i.e. even) value by the EXIT routine.
> If the severity is S (succes) or I (informational) and W (warning)
the procedure returns to caller, unless LIB__SIGNAL_STOP is used to terminate.
MODIFICATION HISTORY:
SEP-1992, Paul Hick (UCSD/CASS), based on DCL procedure Say
NOV-1994, Paul Hick (UCSD/CASS)
- Check the symbol LIB__SIGNAL_QUIET to determine whether the error message
should be displayed.
MAY-1999, Paul Hick (UCSD/CASS)
- Originally, if the symbol LIB__SIGNAL_FILE was set, the file 'say.txt' would
be opened and closed in each Say call. NT has problems with this. I am not sure
why, but I suspect there is some limit on the number of files that can be opened.
Now the file stays open as long as the symbol LIB__SIGNAL_FILE is set.
AUG-1999, Paul Hick (UCSD/CASS)
- The error code passed to iOSExitCmd includes the 'Inhibit display' bit now
only on VMS.
FEB-2005, Paul Hick (UCSD/CASS)
Added iHideLogical call to process cP4.
JAN-2006, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
Added <time> option for cP4
[Previous]
[Next]
NAME:
say_fts
PURPOSE:
Processes error stack of cfitsio package
CATEGORY:
ucsd/for/gen/lib
CALLING SEQUENCE:
subroutine say_fts(cSay,cSeverity,istat)
INPUTS:
cSay character*(*) passed to Say
cSeverity character*(*) passed to Say
istat integer error code from FITS routine
CALLS: ***
FTGMSG, Say, cInt2Str, itrim
CALLED BY:
BList_NSO_NOAA, BList_WSO_NOAA, BRead_WSO, smei_cal_read, smei_cal_write
smei_frm_fts, smei_frm_fts_axis, smei_frm_fts_base, smei_frm_fts_eph
smei_frm_read, smei_frm_read_get_sdark, smei_frm_write, smei_get_glare
smei_get_lsff, smei_get_starmask, smei_orb, smei_orb_cal_name, smei_orb_camera
smei_orb_min_name, smei_orb_min_number, smei_orb_name, smei_orb_number
smei_orb_read, smei_orb_time, smei_orb_version, smei_orb_write, smei_sky_iread
smei_sky_read, smei_skyd_fts, smei_skyd_go, smei_skyd_init, smei_skyd_make
smei_skyd_sky
PROCEDURE:
Processes the Fits error stack; then calls Say with
cSeverity to control program continuation.
MODIFICATION HISTORY:
DEC-2005, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
[Previous]
[Next]
NAME:
SC_ECLIP
PURPOSE:
Calculate heliocentric or topocentric (s/c-centered) ecliptic
coordinates (longitude,latitude, elongation and distance) for the
point P closest to the Sun along each Helios line of sight
(i.e. each photometer-sector combination; SC_ECLIP) and for the
90 degree photometer (SC_ECLIP90)
CALLING SEQUENCE:
subroutine SC_ECLIP(iScIn,IBS,IBE,HLNG,HLAT,HR,HELO)
INPUTS:
iScIn integer +/-1=Helios A, +/-2=Helios B
(positive: returns heliocentric values
negative: returns topocentric values)
IBS integer start sector
IBE integer end sector
IBS and IBE define the range of sectors used and may be given
as normal sector numbers (1,..,32) or modified sector numbers
(-15,..,16). IBS and IBE are used to dimension the output
arrays.
OUTPUTS: (for SC_ECLIP90 the outputs are scalars)
HLNG(IBS:IBE,2) real relative ecliptic longitude P deg in [0,360]),
i.e. the heliocentric difference lng(P)-lng(s/c) or the
topocentric difference lng(P)-lng(Sun)
HLAT(IBS:IBE,2) real ecliptic latitude of P (deg in [-90,90])
HR (IBS:IBE,2) real distance of P (units of the Sun-s/c distance)
HELO(IBS:IBE,2) real elongation of P (deg) (+ for East; - for West)
CALLS: ***
POINT_ON_LOS, Say, acosd, cosd
CALLED BY:
READ_HOS
RESTRICTIONS:
> The spacecraft is supposed to move in the ecliptic
PROCEDURE:
> First calculate azimuth XLNG and elevation XLAT of the line of sight as
defined by a photometer-sector combination. These angles refer to a
spacecraft-centered ecliptic coordinate system (+Z-axis towards ecliptic
North and the +X-axis towards the Sun. The phase angle (measured
counter-clockwise) increases/decreases with sector number for HELIOS
A/B. HELIOS A looks south of ecliptic (XLAT<0); HELIOS B north (XLAT>0).
> The sector numbering is assumed to be in the positive sense using the
spin axis as Z-axis starting at the S/C-Sun direction.
For Helios A (spin axis to North) sector 1 is the first sector eastward
of the S/c-Sun direction; for Helios B (spin axis to South) sector 1
is the first westward sector.
> Since the sector azimuth offsets are taken into account the results
for sectors 17-32 are almost, but not quite symmetrical relative to
sectors 1-16
!> I'm not sure of the sign for the azimuth offset for Helios B. It may
have the wrong sign now.
> If the s/c is located at 1 AU and at ecliptic longitude 0, HLNG and
HLAT become the heliocentric ecliptic coordinates of P and HR the
distance P-Sun in AU.
> The heliocentric elongation is the angle P-Sun-Sc;
the topocentric elongation is the angle P-Sc-Sun.
> The sign of the elongation is used to indicate wheter the point
P lies east of west of the Sun as seen from the spacecraft.
HELO>0 towards the east; HELO<0 towards the west. The sign of HELO will
the same for heliocentric and topocentric cases.
MODIFICATION HISTORY:
APR-1992, Paul Hick (UCSD); modification of SC_ECLIPTIC
[Previous]
[Next]
NAME:
SC_ECLIP90
PURPOSE:
Calculate heliocentric or topocentric (s/c-centered) ecliptic
coordinates (longitude,latitude, elongation and distance) for the
point P closest to the Sun along each Helios line of sight
(i.e. each photometer-sector combination; SC_ECLIP) and for the
90 degree photometer (SC_ECLIP90)
CALLING SEQUENCE:
entry SC_ECLIP90(iScIn,GLNG,GLAT,GR,GELO)
INPUTS:
iScIn integer +/-1=Helios A, +/-2=Helios B
(positive: returns heliocentric values
negative: returns topocentric values)
OUTPUTS:
GLNG real relative ecliptic longitude P deg in [0,360]),
i.e. the heliocentric difference lng(P)-lng(s/c) or the
topocentric difference lng(P)-lng(Sun)
GLAT real ecliptic latitude of P (deg in [-90,90])
GR real distance of P (units of the Sun-s/c distance)
GELO real elongation of P (deg) (+ for East; - for West)
CALLS: ***
POINT_ON_LOS, Say, acosd, cosd
CALLED BY:
READ_HOS
RESTRICTIONS:
> The spacecraft is supposed to move in the ecliptic
PROCEDURE:
Entry point in SC_ECLIP
MODIFICATION HISTORY:
APR-1992, Paul Hick (UCSD); modification of SC_ECLIPTIC
[Previous]
[Next]
NAME:
SC_ECLIPTIC
PURPOSE:
Calculates for a given sector line of sight direction the heliocentric
ecliptic coordinates of the point P on the line of sight where the bulk
of the electrons are supposed to be located.
The spacecraft is supposed to move in the ecliptic.
CATEGORY:
CALLING SEQUENCE:
subroutine SC_ECLIPTIC(iSc,SectIn,PP,ELO,LNG,LAT,R_XH)
INPUTS:
iSc integer spacecraft; 1=HELIOS A; 2=HELIOS B
SectIn integer sector number (1,..,32) or
modified sector number (-15,..,16)
PP integer photometer number; 1=15 deg.; 2=30 deg.
OUTPUTS: (angles are in degrees)
ELO real elongation; angle (l.o.s. - Sun-Earth line)
LNG real difference of ecliptic longitudes of P and SC
LAT real ecliptic latitude of P
R_XH real distance of P to Sun in units of Sun-SC distance
CALLS: ***
dacosd, dasind, datan2d, dcosd, dsind
PROCEDURE:
ELEV photometer elevation below spacecraft X-Y plane
DAZ lag of photometer azimuth behind nominal value
WIDTH sector width of smallest sectors (in degrees)
Arithmetic is done is double precision
MODIFICATION HISTORY:
1990, Paul Hick (UCSD)
[Previous]
[Next]
NAME:
SD
PURPOSE:
Changing directory.
(Alternative to the VMS LIBCD command procedure)
CATEGORY:
Utility
CALLING SEQUENCE:
program SD
INPUT:
(the input is read from the DCL command line as foreign input)
/action indicates action to be take (only first two chars are tested)
(none) Move to directory P1
/HELP Display help screen
/TOP Move to top directory on current disk
/UP Move to parent directory
/DOWN Move to child directory P1
/SIDE Move to sister directory P1
/TREE Display directory tree from P1 downward
/JUMP Jump to one of the displayed directories
/SWITCH Back to previous directory
/FAST Short cut
For >DOWN and >SIDE a list of valid directories is given if
P1 = "", followed by a prompt (unless there is only one
candidate directory to go to).
P1 indicates directory (exception: P2=? will display a brief HELP)
-- Omitting the argument is the equivalent of a
SHOW DEFAULT
-- The syntax of the argument is as for the SET DEFAULT
command. But:
-- If the disk is not explicitly given, the square brackets
may be omitted
-- If no disk is specified, the current disk is searched.
If the destination is not found the SYS$LOGIN disk and
the SYS$SCRATCH disk are searched
? -- The argument may be a global symbol (the content of
? the symbol is used as destination)
-- The argument may be a logical assigned to a directory
(e.g. SYS$LOGIN, SYS$SCRATCH)
INCLUDE:
include 'dirspec.h'
include 'filparts.h'
CALLS: ***
AskI4, BINROOT, CJUMPSYM, ForeignArg, LocFirst, LocFirstLen, LocLast, SD_DISPJUMP
SD_FAST, SD_HELP, SD_PREPJUMP, SD_PROMPT, SD_TREE, Say, Str2Str, cInt2Str
iCheckDirectory, iFile2Dir, iGetDefaultDir, iGetDirectoryFragment, iGetFileSpec
iGetLogical [1], iGetLogical [2], iGetSymbol [1], iGetSymbol [2]
iGetTopDirectory, iSearch, iSetFileSpec, itrim, uppercase
SIDE EFFECTS:
Change prompt to indicate current directory
PROCEDURE:
Identical to the LIBCD.COM procedure except for minor differences.
> The TREE option displays the directory tree from the current directory
downwards (i.e. does not invoke the symbols LOGINTREE and SCRATCHTREE)
> The change of prompt is done on program exit by issuing the DCL
'SET PROMPT' command as argument to OSExitCmd.
MODIFICATION HISTORY:
OCT-1991/SEPT-1992, Paul Hick (UCSD),
F77 version of the DCL procedure LIBCD.COM
NOV-1994, Paul Hick (UCSD), major revamp
[Previous]
[Next]
NAME:
SD_SCAN
PURPOSE:
CALLING SEQUENCE:
subroutine SD_SCAN(cDefDir,cTreeTop,cTree,cDest,cDir)
INPUTS:
cTreeTop character*(*) top directory of cTree
(full directory spec)
cTree character*(*) tree info
cDefDir character*(*) reference directory (= working dir)
cDest character*(*) abbreviation destination spec
OUTPUTS:
cDir character*(*) full directory spec
cDest character*(*) value NOT preserved
CALLS: ***
Int2Str, LocFirst, LocFirstLen, LocLast, SD_SCAN_CHECK, Say, Str2Flt, Str2Str
iGetDirectoryFragment, iGetParentDirectory, iGetSymbol [1], iGetSymbol [2]
iSetFileSpec, iSetSymbol [1], iSetSymbol [2], itrim
INCLUDE:
include 'dirspec.h'
PROCEDURE:
> The destination spec cDest identifies the destination directory:
1. Incomplete directory name:
cDest = 'text' refers to any directory `text*.dir'
2. Complete directory name:
cDest = 'text.' refers to a directory `text.dir'
3. Chain of directory names, with incomplete last fragment:
cDest = 'phick.c' refers to a directory [*.phick.*]c*.dir
3. Chain of directory names, with complete last fragment:
cDest = 'phick.c.' refers to a subdirectory [*.phick.*]c.dir
[Previous]
[Next]
NAME:
SD_TREE
PURPOSE:
Displays a rudimentary directory tree from the top directory downwards
CALLING SEQUENCE:
subroutine SD_TREE(bDisplay,cTopDir,cTree)
INPUTS:
bDisplay .TRUE. : display tree on screen
.FALSE.: don't display (just build cTree)
cTopDir top directory of tree (fully qualified directory name)
OUTPUTS:
cTree string containing tree information in form
(sub1(sub2,sub3(sub4,sub5),sub6))
On Unix and Dos sub1 will be the null string when
scanning from the root directory downward.
Otherwise sub1 will be the last subdirectory fragment
of cTopDir, i.e. if cTopDir='/mnt/work/temp' then
sub1='temp'.
cTopDir and cTree together provide a complete
description of the directory tree attached to cTopDir.
CALLED BY:
SD
INCLUDE:
include 'dirspec.h'
include 'filparts.h'
include 'openfile.h'
CALLS: ***
AskYN, LocFirstLen, Say, Str2Str, bOpenFile, iCheckDirectory, iFilePath, iFreeLun
iGetDirectoryFragment, iGetFileSpec, iSearch, iSetFileSpec, itrim
MODIFICATION HISTORY:
[Previous]
[Next]
NAME:
SetGipsy
PURPOSE:
Set logical $CAM for GIPSY programs. Return data type (edited or
unedited data) and modified Julian day for earliest data file
CALLING SEQUENCE:
subroutine SetGipsy(cDat,iOffUT,iEdt,MJDfrst,MJDlast)
INPUTS:
cDat character*(*) logical name pointing to location of
data files
iOffUT integer offset between local time and UT
OUTPUTS:
iEdt integer 0 = Unedited data; 1 = Edited data
MJDfrst integer Modified Julian day for earliest data file
MJDlast integer Modified Julian day for most recent file
CALLS: ***
AskWhat, Say, SetLog2Dir, iDeleteLogical [1], iDeleteLogical [2], iFilePath
iGetFileSpec, iGetLogical [1], iGetLogical [2], iSetFileSpec, iSetLogical [1]
iSetLogical [2]
CALLED BY:
SetGrid, ipsd, ipsdt
INCLUDE:
include 'filparts.h'
include 'sun.h'
include 'dirspec.h'
PROCEDURE:
MODIFICATION HISTORY:
JAN-1992, Paul Hick (UCSD)
JUL-1993, Paul Hick (UCSD), added search for MJDlast
SEP-1999, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
hardwired return values MJDfrst = 48180 and MJDlast = 49622
As a result the input value iOffUT is not used anymore.
[Previous]
[Next]
NAME:
SetGrid
PURPOSE:
Set the range in Carrington variable to be used for a tomographic reconstruction
CATEGORY:
Tomography: initialization
CALLING SEQUENCE:
subroutine SetGrid(bForecast, nCar,JDCar, XCbegMAT,XCendMAT,XCbegROI,XCendROI,
& XCtst1,XCtst2,MJDref, bGCamb, MJDfrst,MJDlast,cCam,iEdt, NT)
INPUTS:
bForecast logical
bGCamb logical
OUTPUTS:
nCar integer
JDCar(nCar) real*8 Start times of Carrington rotations (Julian days)
NCoff integer Offset of JDCarr index and Carrington rotation number
XCbegROI real
XCendROI real
Carrington variables defining 'region of interest':
only used to output part of [XCbeg,XCend] in Write3D_nv
XCbeg real
XCend real
Carrington variables marking limits of arrays
XCtst1 real
XCtst2 real
limits on Carrington variable used to select
lines of sight (passes to ReadVIPS,ReadGIPS)
Only used by ReadGIPS:
MJDfrst integer Modified Julian day for earliest data file
MJDlast integer Modified Julian day for most recent file
cCam character*(*) logical name for Cambridge directory
iEdt integer 0 = Unedited data; 1 = Edited data
CALLS: ***
AdjustJDCar, AskI4, AskR4, AskR8, DATE_DOY, EARTH, FLINT8, Julian, Local2UT, MAP_TZERO
N_CARRINGTON, Say, SetGipsy, T3D_iget, T3D_iset, T3D_set, XMAP_SC_POS
CALLED BY:
ipsg2, ipsg2s, ipsg2t
EXTERNAL:
external EARTH
INCLUDE:
include 'dirspec.h'
include 'sun.h'
include 't3d_param.h'
include 't3d_array.h'
PROCEDURE:
Lots of user prompts
MODIFICATION HISTORY:
SEP-1999, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
[Previous]
[Next]
NAME:
SetLog2Dir
PURPOSE:
Set logical to directory containing files matching specified wildcard
CALLING SEQUENCE:
subroutine SetLog2Dir(iPrompt,cLog,cWild,cFound)
INPUTS:
iPrompt integer 1 = prompt for directory until
requested files are located
2 = do not prompt
-2 = do not prompt, do not delete logical
cLog*(*) character name of logical
cWild*(*) character file name wildcard
(NO directory specification permitted)
OUTPUTS:
cFound*(*) character first file name matching wildcard
= ' ' if no file is found
If necessary the logical is entered into the PROCESS table
CALLS: ***
AskChar, Say, iDeleteLogical [1], iDeleteLogical [2], iGetDefaultDir, iGetFileSpec
iGetLogical [1], iGetLogical [2], iSearch, iSetFileSpec, iSetLogical [1]
iSetLogical [2], itrim, uppercase
CALLED BY:
SetGipsy, SetRotations
INCLUDE:
include 'filparts.h'
include 'dirspec.h'
PROCEDURE:
> If iPrompt=1 then the logical is defined upon return and
cFound contains the first file name matching the wildcard (if necessary
after prompting for a directory).
> If iPrompt=2 then two things can happen on return
- The logical is still defined and a matching file is located.
cFound contains the first matching file name upon return
- The logical is not defined, and cFound = ' ', because
1. the logical was not defined in the first place
2. no matching file name was found
3. matching files were also found in the current directory
> If iPrompt=-2 then three things can happen on return
- The logical is not defined, and cFound = ' ', because
1. the logical was not defined in the first place
- The logical is still defined and a matching file is located.
cFound contains the first matching file name upon return
- The logical is still defined, but cFound = ' ', because
2. no matching file name was found
3. matching files were also found in the current directory
> If a matching file name is returned in cFound, then also iSetFileSpec
has been called to fill the parse structure.
The following steps are taken to set the logical and test the wildcard:
>1 Translate the logical cLog
>2 If the logical is not defined, go to step 6
>3 If the logical is defined then test the wildcard.
>4 If a match is found, RETURN, UNLESS the current directory is different
from the logical directory, and also contains matching files
>5 Undefine the logical (happens if the logical directory does not
contain matching files or the ambiguity with the current directory
arises (see previous step).
>6 RETURN if iPrompt=0 (cFound=' ', logical does not exist (anymore))
>7 Test the wildcard in the default directory. If a match is found
offer it as the default choice for the directory prompt
>8 Prompt for directory until a match for the wildcard if found
>9 Set the logical to the selected directory
MODIFICATION HISTORY:
SEP-1992, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
[Previous]
[Next]
NAME:
SetRotations
PURPOSE:
Use specified wildcard to locate directory with data files for the
Carrington programs. If located, define a logical pointing to the
data directory.
Also return first and last Carrington rotations numbers for which files
are available.
CALLING SEQUENCE:
subroutine SetRotations(iPrompt,cWild,IClo,IChi)
INPUTS:
iPrompt integer = 0/1
0 : check directory assigned to logical only.
1 : check directory assigned to logical. If unsuccessful, prompt
for directories until data files are located
cWild*(*) character wildcard used to search for data files
(only file name and type are used)
OUTPUTS:
IClo integer First and ..
IChi integer last Carrington rotation located
CALLS: ***
Int2Str, Int2StrSet, Say, SetLog2Dir, Str2Str, Str2StrSet, iFilePath, iGetFileSpec
iSearch, iSetFileSpec, itrim
INCLUDE:
include 'filparts.h'
include 'str2str_inc.h'
include 'dirspec.h'
PROCEDURE:
> The wildcard is used to search for data files.
The Carrington rotation should be encoded into file name as a 4 digit
integer. Mark the location with the 4 char string %%%% or ####.
(use #### if there is there is another %%%% present in the wildcard
preceding the location of the Carrington number.
> The wildcard must have the same number of characters as the real
file name+file extension, i.e. do NOT use the wildcard *, but only
the single character wildcard %.
> The file type (extension) is used to construct the name of the logical
assigned to the data directory.
> If the logical is already assigned to a directory, that directory is
searched first. If data files are found, the value is retained. If not,
the logical is deassigned.
> If no files are found in the previous step, then
- if iPrompt = 0 then return IClo = IChi = 0
- if iPrompt = 1 continue to prompt for a directory until one is specified
which contains data files or until program is aborted.
MODIFICATION HISTORY:
JUL-1993, Paul Hick (UCSD/CASS; pphick@ucsd.edu), modification of SetGipsy
[Previous]
[Next]
NAME:
shift_MOD
PURPOSE:
To accumulate shift values at given heights and times to use in determining
model projections to a lower source surface given the velocities at each point
in time. The shifts give the average longitude, latitude and time shifts in
fractions of a Carrington rotation required to get to the input reference
map at each longitude, latitude, height and time point.
CATEGORY:
Data processing
CALLING SEQUENCE:
call shift_MOD(NLNGM,NLATM,NMAPM,NTM,V3,D3,V3L,D3L,R_MOD,IYR,DOY,IYRL,DOYL,ICTX,FICTX,ICTXL,FICTXL,
V3D,D3D,V3DL,D3DL,V3DTMP,D3DTMP,
nCar,JDCar,NCoff,xcbe,xctbeg,xctend,aLng,nLng,nLat,nMap,nT,rr,drr,Rconst,
cLrV,cLrD,vTmp,dTmp,vv,dd,xcshift,vRatio,dRatio)
INPUTS:
THESE ARE MODEL INPUTS
NLNGM integer # of model longitude points (inertial frame includes both 0 and 360 deg.)
NLATM integer # of model latitude points (inertial frame from -90 to + 90 deg.)
NMAPM integer # of model heights (heights must go from same as tomography source surface
up to at least 3.0 AU)
V3(NLNGM,NLATM,NMAPM,3) real 3D velocity (west +, north +, outward +) input from model in km/sec at time IYR + DOY
D3(NLNGM,NLATM,NMAPM) real 3D density input from model in particles/cm^3 at time IYR + DOY
V3L(NLNGM,NLATM,NMAPM,3) real Save space for last 3D velocity input from model in km/sec at time IYRL + DOYL
D3L(NLNGM,NLATM,NMAPM) real Save space for last 3D density input from model in particles/cm^3 at time IYRL + DOYL
R_MOD(NMAPM) real Heights of the model calculation
IYR integer Year of the current model calculation (e.g., 20XX) (e.g., 2000)
DOY real Day of year for the current model calculation (begins at 1.0 on the first day)
IYRL integer Save space for the last year of the model calculation.
DOYL real Save space for the last day of year for the model calculation.
ICTX integer Beginning Carrington variable source surface at this time. (e.g., 1965)
FICTX real Beginning Carrington variable source surface fraction at this time. (e.g., 0.34567)
ICTXL integer Save space for the beginning Carrington variable source surface at the last time.
FICTXL real Save space for the beginning Carrington variable source surface fraction the last time.
Note - The save space variables need not be set, just allocated a space.
V3D((NLNGM-1)*3+1,NLATM,NMAPM,3) real Scratch arrays for model from calling program
D3D((NLNGM-1)*3+1,NLATM,NMAPM) real
V3DL((NLNGM-1)*3+1,NLATM,NMAPM,3) real
D3DL((NLNGM-1)*3+1,NLATM,NMAPM) real
V3DTMP(nLngt,nLatt,2,2,3) real
D3DTMP(nLngt,nLatt,2,2,3) real
THESE ARE TOMOGRAPHY INPUTS AND THEIR VALUES
nCar integer # Carrington rotations
JDCar real*8 Julian Date at beginning of rotations
NCoff integer Carrington variable offset
xcbe(2,nT) real Tomography boundary values of time maps (passed through)
xctbeg real Tomography beginning time interval (passed through)
xctend real Tomography ending time interval (passed through)
aLng real Rotations per nLng1 (passed through)
nLng integer # tomography model longitude points (passed through)
nLat integer # tomography model latitude points (passed through)
nMap integer # tomography model tomographic heights (passed through)
nT integer # tomography model time intervals (passed through)
rr real Height of tomographic source surface (in AU). (must be identical to model value)
drr real Distance between points in tomographic height array (passed through)
Rconst real Tomography time constant ~25.38/27.275, but specific to the interval.
cLrV real Velocity map radius filter distance (in interval fractions) (passed through)
cLrD real Density map radius filter distance (in interval fractions) (passed through)
vTmp(nLng,nLat) real Internal scratch array
dTmp(nLng,nLat) real Internal scratch array
OUTPUTS:
THESE ARE OUTPUTS TO THE TOMOGRAPHY PROGRAM
vv(nLng,nLat,nT) real Map of velocity values at a given source surface height RR
dd(nLng,nLat,nT) real Map of density values at a given source surface height RR
xcshift(nLng,nLat,nMap,nT,3) real xcshift contains the final shifts for the tomography program
at the times and heights it needs in the coordinates it needs.
vRatio (nLng,nLat,nMap,nT) real velocity ratios
dRatio (nLng,nLat,nMap,nT) real density ratios
CALLS: ***
ArrR4Constant, ArrR4GetMinMax, ArrR4Zero, BadR4, EARTH, FLINT, Get3DTval, GridSphere2D
XMAP_SC_POS, atan2d
CALLED BY:
sim_MOD
PROCEDURE:
> xcshift(i,j,n,itim,l) is the shift needed to trace location (i,j,n,itim,3) back
to the reference surface at a given time, i.e.:
xcshift(i,j,n,itim,1) defines the location of the origin of the point in longitude
at the reference surface in terms of a modified Carrington variable.
xcshift(i,j,n,itim,1) (longitude) will be negative above the reference
surface (n>1).
xcshift(i,j,n,itim,2) defines the location of the origin of the point in latitude
at the reference surface in terms of degrees.
xcshift(i,j,n,itim,3) defines the location of the origin of the point in time
at the reference surface in terms of a modified Carrington variable.
The time shift in Carrington coordinates will point to an earlier or the
same time.
Bad grid points in xcshift(i,j,n,itim,l) are filled with GridSphere2D.
The values of vRatio and dRatio are used to determine the changes
in the velocities and densities relative to their values at the source surface
at the point at the height i,j,n,itim,l.
MODIFICATION HISTORY:
APR-2002, B. Jackson (UCSD)
[Previous]
[Next]
NAME:
shift_MOD
PURPOSE:
To accumulate shift values at given heights and times to use in determining
model projections to a lower source surface given the velocities at each point
in time. The shifts give the average longitude, latitude and time shifts in
fractions of a Carrington rotation required to get to the input reference
map at each longitude, latitude, height and time point.
CATEGORY:
Data processing
CALLING SEQUENCE:
call shift_MOD(NLNGM,NLATM,NMAPM,NTM,V3,D3,V3L,D3L,R_MOD,IYR,DOY,IYRL,DOYL,ICTX,FICTX,ICTXL,FICTXL,
V3D,D3D,V3DL,D3DL,V3DTMP,D3DTMP,
nCar,JDCar,NCoff,xcbe,xctbeg,xctend,aLng,nLng,nLat,nMap,nT,rr,drr,Rconst,
cLrV,cLrD,vTmp,dTmp,vv,dd,xcshift,vRatio,dRatio)
INPUTS:
THESE ARE MODEL INPUTS
NLNGM integer # of model longitude points (inertial frame includes both 0 and 360 deg.)
NLATM integer # of model latitude points (inertial frame from -90 to + 90 deg.)
NMAPM integer # of model heights (heights must go from same as tomography source surface
up to at least 3.0 AU)
V3(NLNGM,NLATM,NMAPM,3) real 3D velocity (west +, north +, outward +) input from model in km/sec at time IYR + DOY
D3(NLNGM,NLATM,NMAPM) real 3D density input from model in particles/cm^3 at time IYR + DOY
V3L(NLNGM,NLATM,NMAPM,3) real Save space for last 3D velocity input from model in km/sec at time IYRL + DOYL
D3L(NLNGM,NLATM,NMAPM) real Save space for last 3D density input from model in particles/cm^3 at time IYRL + DOYL
R_MOD(NMAPM) real Heights of the model calculation
IYR integer Year of the current model calculation (e.g., 20XX) (e.g., 2000)
DOY real Day of year for the current model calculation (begins at 1.0 on the first day)
IYRL integer Save space for the last year of the model calculation.
DOYL real Save space for the last day of year for the model calculation.
ICTX integer Beginning Carrington variable source surface at this time. (e.g., 1965)
FICTX real Beginning Carrington variable source surface fraction at this time. (e.g., 0.34567)
ICTXL integer Save space for the beginning Carrington variable source surface at the last time.
FICTXL real Save space for the beginning Carrington variable source surface fraction the last time.
Note - The save space variables need not be set, just allocated a space.
V3D((NLNGM-1)*3+1,NLATM,NMAPM,3) real Scratch arrays for model from calling program
D3D((NLNGM-1)*3+1,NLATM,NMAPM) real
V3DL((NLNGM-1)*3+1,NLATM,NMAPM,3) real
D3DL((NLNGM-1)*3+1,NLATM,NMAPM) real
V3DTMP(nLngt,nLatt,2,2,3) real
D3DTMP(nLngt,nLatt,2,2,3) real
THESE ARE TOMOGRAPHY INPUTS AND THEIR VALUES
nCar integer # Carrington rotations
JDCar real*8 Julian Date at beginning of rotations
NCoff integer Carrington variable offset
xcbe(2,nT) real Tomography boundary values of time maps (passed through)
xctbeg real Tomography beginning time interval (passed through)
xctend real Tomography ending time interval (passed through)
aLng real Rotations per nLng1 (passed through)
nLng integer # tomography model longitude points (passed through)
nLat integer # tomography model latitude points (passed through)
nMap integer # tomography model tomographic heights (passed through)
nT integer # tomography model time intervals (passed through)
rr real Height of tomographic source surface (in AU). (must be identical to model value)
drr real Distance between points in tomographic height array (passed through)
Rconst real Tomography time constant ~25.38/27.275, but specific to the interval.
cLrV real Velocity map radius filter distance (in interval fractions) (passed through)
cLrD real Density map radius filter distance (in interval fractions) (passed through)
vTmp(nLng,nLat) real Internal scratch array
dTmp(nLng,nLat) real Internal scratch array
OUTPUTS:
THESE ARE OUTPUTS TO THE TOMOGRAPHY PROGRAM
vv(nLng,nLat,nT) real Map of velocity values at a given source surface height RR
dd(nLng,nLat,nT) real Map of density values at a given source surface height RR
xcshift(nLng,nLat,nMap,nT,3) real xcshift contains the final shifts for the tomography program
at the times and heights it needs in the coordinates it needs.
vRatio (nLng,nLat,nMap,nT) real velocity ratios
dRatio (nLng,nLat,nMap,nT) real density ratios
CALLS: ***
ArrR4Constant, ArrR4GetMinMax, ArrR4Zero, BadR4, EARTH, FLINT, Get3DTval, GridSphere2D
XMAP_SC_POS, atan2d, tand
CALLED BY:
sim_MOD
PROCEDURE:
> xcshift(i,j,n,itim,l) is the shift needed to trace location (i,j,n,itim,3) back
to the reference surface at a given time, i.e.:
xcshift(i,j,n,itim,1) defines the location of the origin of the point in longitude
at the reference surface in terms of a modified Carrington variable.
xcshift(i,j,n,itim,1) (longitude) will be negative above the reference
surface (n>1).
xcshift(i,j,n,itim,2) defines the location of the origin of the point in latitude
at the reference surface in terms of degrees.
xcshift(i,j,n,itim,3) defines the location of the origin of the point in time
at the reference surface in terms of a modified Carrington variable.
The time shift in Carrington coordinates will point to an earlier or the
same time.
Bad grid points in xcshift(i,j,n,itim,l) are filled with GridSphere2D.
The values of vRatio and dRatio are used to determine the changes
in the velocities and densities relative to their values at the source surface
at the point at the height i,j,n,itim,l.
MODIFICATION HISTORY:
APR-2002, B. Jackson (UCSD)
[Previous]
[Next]
NAME:
sim_MOD
PURPOSE:
To make a time-dependent model at even heights to use in determining projections.
The model gives the 3D velocities and densities in a 360 degree model from a
specified Carrington rotation interval longitude location at each height at
a given time in UT (iyr, doy) from the beginning time also specified in
UT (iyr, doy).
The subroutine is inserted into the tomography mkshiftn subroutine and
passes those arrays required of the tomography program that are to be used
in the subroutine shift_MOD required to be called by the inertial MHD
(or other inertial) program that provides the shifts and density and velocity
variations required for the tomography program to work.
CATEGORY:
Data processing
CALLING SEQUENCE:
call sim_MOD(XCbe,XCtbeg,XCtend,ALng,aNday,nLng,nLat,nMap,nT,
nCar,JDCar,NCoff,VV,DD,XCshift,Vratio,Dratio,RR,dRR,FALLOFF,CLRV,CLRD)
INPUTS:
XCbe(2,nT) real Boundary values of time maps
XCtbeg real Beginning time interval
XCtend real Ending time interval
Alng real Rotations per nLng1
aNday real # of days per time interval
nLng integer # longitude points
nLat integer # latitude points
nMap integer # heights (height begins at Sun__RAu AU)
nT integer # time intervals
nCar intger # beginning Carrington variable Julian dates
JDCar real*8 Carrington variable beginning Julian dates
NCoff integer Carrington variable offset
VV(nLng,nLat,nT)real Map of velocity values at a given height RR
DD(nLng,nLat,nT)real Map of density values at a given height RR
RR real Distance above sun for reference velocity map
dRR real Distance between individual maps (in AU)
FALLOFF real Power of density falloff (usually about 2.1 for the HELIOS tomography)
CLRV real Velocity map radius filter distance
CLRD real Density map radius filter distance
OUTPUTS:
XCshift(nLng,nLat,nMap,nT,3) real XCshift contains the final shifts at all heights
in terms of fractions of a Carrington rotation
Vratio (nLng,nLat,nMap,nT) real velocity ratios
Dratio (nLng,nLat,nMap,nT) real density ratios
CALLS: ***
ArrR4GetMinMax, BadR4, FLINT, GridSphere2D, Julian, shift_MOD [1], shift_MOD [2]
surf_MOD
PROCEDURE:
> XCshift(I,J,N,K,3) is the shift needed to trace location (I,J,N,K) back
to the reference surface at a given time, i.e.
XC = XCfrac(I)+XCshift(I,J,N,K,3) defines the origin of point (I,J,N,K,3)
at the reference surface in terms of a modified Carrington variable.
XCshift(I,J,N,K,3) will be negative above the reference surface (N>nRR),
zero at the reference surface (N=nRR) and will point to an earlier
or the same time. Bad grid points in VV and DD are filled with
GridSphere2D
MODIFICATION HISTORY:
APR-2002, B. Jackson (UCSD)
[Previous]
[Next]
NAME:
Simpson
PURPOSE:
Numerical integration of function of one variable using Simpson rule
CALLING SEQUENCE:
function Simpson(F,A,B,DEL,MAXN,N)
INPUTS:
F real function; declared external in caller
A,B real integration range
DEL real accuracy
MAXN integer maximum number of iterations
OUTPUTS:
Simpson real result of integration
N integer 0: no convergence
1: if A=B (then also R=0)
CALLED BY:
AIPS_WTF, IPSBase
PROCEDURE:
> If DEL <=0 then DEL=1x10^-4 is used
> If MAXN< 2 then MAXN=2 is used
MODIFICATION HISTORY:
[Previous]
[Next]
NAME:
sind
CALLING SEQUENCE:
entry sind(a)
INPUTS:
a real angle in degrees
CALLED BY:
AsymDust, CheckMass, DustAsymmetry, ElSunDistance, EqKepler, KeplerOrbit
LOSPosition, MapWarp, MkVMap, MkVMaptdN, MkVModel, MkVModeltd, READ_HOS, SindLookup
SphereWeight, THOM_WTF, ThomsonMidpointFar, Time2PrecesssionLtd
SEE ALSO:
cosd
MODIFICATION HISTORY:
JAN-2001, Paul Hick (UCSD; pphick@ucsd.edu)
[Previous]
[Next]
NAME:
SindLookup
PURPOSE:
Calculates sin(x) using lookup table
CATEGORY:
Math
CALLING SEQUENCE:
function SindLookup(X)
INPUTS:
X real X-coordinate (degrees)
OUTPUTS:
F real sin(x) from table lookup
CALLS: ***
FLINT, sind
SEE ALSO:
CosdLookup, GaussLookup
RESTRICTIONS:
The table lookup runs up to 10. For larger X-values, the return value is zero
MODIFICATION HISTORY:
SEP-2003, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
[Previous]
[Next]
NAME:
smei_axis_cam
PURPOSE:
Convert polar CCD coordinates to sky coordinates
in camera frame, and v.v
CALLING SEQUENCE:
subroutine smei_axis_cam(id,icam,mode,dr,phi,rx,ry,rz,tx,ty)
INPUTS:
id integer id=0: CCD pixel coord to camera sky coord
id=1: camera sky coord to CCD pixel coord
icam integer camera id (1,2,3)
mode integer mode (0,1,2)
id=0:
dr double precision radial distance to optical axis in
units of engineering mode pixels
phi double precision angle from optical axis in degrees
id=1:
rx double precision x-component of unit vector
ry double precision y-component of unit vector
rz double precision z-component of unit vector (always positive)
OUTPUTS:
id=0:
rx double precision x-component of unit vector
ry double precision y-component of unit vector
rz double precision z-component of unit vector (always positive)
id=1:
dr double precision radial distance to optical axis in
units of engineering mode pixels
phi double precision angle from optical axis in degrees
tx double precision theta-x = arcsin(rx)
ty double precision theta-y = arcsin(ry)
CALLS: ***
BadR8, datan2d, dsind
CALLED BY:
smei_skyd_fill, smei_skyd_flush, smei_skyd_fts, smei_skyd_init, smei_skyd_make
smei_skyd_sky, smei_skyd_sort
RESTRICTIONS:
The input values for x,y need to be sensible, i.e. not too far
outside the field of view.
RESTRICTIONS:
If a unit vector is specified (id=1) then the conversion
is only done if the location is within a reasonable
distance of the fov (currently abs(tx) < 45 and abs(ty) < 10
degrees. For locations outside this range dr and phi are
set to BadR8() on return.
PROCEDURE:
(rx,ry,rz) is a unit vector representing the location
on the sky of (x,y) on the CCD, i.e. rx,ry,rz are the
direction cosines.
Quadratic coefficients from Andys July 2001 memo. In addition some
ad-hoc stretching of tx and ty is done
MODIFICATION HISTORY:
FEB-2006, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
[Previous]
[Next]
NAME:
smei_axis_ccd
PURPOSE:
Convert rectangular CCD coordinates to polar coordinates
relative to optical axis and v.v.
CALLING SEQUENCE:
subroutine smei_axis_ccd(id,icam,mode,x,y,dr,phi,r)
INPUTS:
id integer id=0: CCD pixel coord to camera sky coord
id=1: camera sky coord to CCD pixel coord
icam integer camera id (1,2,3)
mode integer mode (0,1,2)
id=0:
x,y double precision pixel coordinates for specified input mode
id=1:
dr double precision radial distance to optical axis in
units of engineering mode pixels
phi double precision angle from optical axis in degrees
(usually dr,phi are output from smei_axis_cam)
OUTPUTS:
id=1:
dr double precision radial distance to optical axis in
units of engineering mode pixels
phi double precision angle from optical axis in degrees
(usually dr,phi are output from smei_axis_cam)
id=0:
x,y double precision pixel coordinates for specified input mode
r double precision radial distance to origin of polar
transformation, i.e. r,phi are polar coordinates
on the CCD, and r = r0+dr, where r0 is the
distance of the optical axis from the origin.
CALLS: ***
datan2d, dcosd, dsind
CALLED BY:
smei_skyd_fts, smei_skyd_init, smei_skyd_make, smei_skyd_sky
SEE ALSO:
smei_axis_cam
PROCEDURE:
Binned (mode 1,2) and unbinned (mode 0, engineering mode) pixel
indices are related by (nbin = 2^mode):
(unbinned index) = nbin*(binned index)-0.5*(nbin-1)
MODIFICATION HISTORY:
FEB-2006, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
[Previous]
[Next]
NAME:
smei_base
PURPOSE:
Determines pedestal & dark current, finds measles
CALLING SEQUENCE:
program smei_base
INPUTS:
SMEI data frames read from specified source (usually the
SMEI frame data base)
smei_base -start_time=<start_time> -stop_time=<stop_time>
-camera=<1,2,3> [NOT YET: -mode=<0,1,2>]
-source=<source> -destination=<destination>
<start_time> and <stop_time> bracket the time period to be processed.
The times are specified either as orbit numbers or as a UT time in the
format YYYY_DOY_hhmmss (i.e. the standard SMEI time format).
<start_time> MUST be specified. If <stop_time> is not specified than a
single orbit starting at <start_time> is processed.
The camera number (1,2 or 3) MUST be specified.
<source> is the source directory where SMEI frames are picked up.
<destination> is the destination directory for the updated SMEI frames
OUTPUTS:
Updated SMEI frames as Fits files in <destination>
INCLUDE:
include 'openfile.h'
include 'smei_frm_layout.h'
include 'smei_frm_basepar.h'
include 'smei_frm_hdr.h'
include 'math.h'
include 'dirspec.h'
include 'filparts.h'
CALLS: ***
ArrR4AddConstant, ArrR4Copy, ArrR4Mask, ArrR4Mean, BadI4, BadR4, BadR4Test
ForeignArgSet, ForeignI4Arg, ForeignR4Arg, Int2Str, Say, Str2Str, Time2Str, bOpenFile
cDbl2Str, cHideLogical, iFilePath, iFreeLun, iGetFileSpec, iOSDeleteFile
iScratchLun, iSetFileSpec, itrim, smei_Time2Split, smei_cal_get, smei_cal_init
smei_foreign, smei_frm_base, smei_frm_c3fudge, smei_frm_c3mask_active
smei_frm_clean, smei_frm_fts, smei_frm_getlist, smei_frm_measle, smei_frm_pickup
smei_frm_read, smei_frm_saturated, smei_frm_stats, smei_frm_write, smei_hdr_str
smei_orb_mkname
PROCEDURE:
smei_base is run on every individual SMEI frame to fill in three groups
of header entries in the Fits header:
1) base-related entries (pedestal, dark current, pattern names, etc.)
2) optical axis entries (RA, Dec, and PA)
These depend on the Coriolis sky-to-spacecraft quaternions and
on the fixed camera-to-spacecraft quaternions
3) unit vectors for Sun, Moon, Venus in the UCSD camera frame, and
eclipse information. These depend on the Coriolis orbital
elements and the quaternions.
If smei_base is first run on a .nic.gz file (which does not contain
any of the above information) all header entries are calculated
and a new .fts.gz file is created (i.e. both header and data frame
are written). This will happen in the conversion of the SMEI
data base from .nic.gz to .fts.gz files.
As of Mar-2005 we do not produce .nic.gz files from the
real-time SMEI data, but create .fts.gz files instead with the
flag SMEI__HDR_BASE_DONE set to zero. These Fits files
do not yet have the base headers filled (group 1 above), while
the unit vectors of Sun, Moon and Venus are probably based
on orbital elements that could be weeks old, and hence may
not be very accurate. If smei_base is first run on these files
then the zero value in SMEI__HDR_BASE_DONE will trigger the
calculation of all three groups of headers. If the source is the
same as the destination, then the existing Fits file is updated
with the header information, i.e. the header is only partially
updated, and the data array remains untouched. If the
destination is different from the origin then a new Fits
file is written. In both cases the flag SMEI__HDR_BASE_DONE
is set to one.
If smei_base is run on a Fits file which already has the
SMEI__HDR_BASE_DONE flag set, then by default no action is taken
(not even when destination and source are different) unless the
version number of smei_base has been increased.
Overide this behavior by setting the -force keyword. This will
trigger a recalculation of all three groups of header entries.
The -savefrm option will do the base calculation and save three
fts files into the destination directory:
- *_0.fts.gz: frame with constant pedestal+dark_current subtracted
- *_1.fts.gz: frame with pedestal and pattern subtracted
- *_2.fts.gz: frame with pedestal and pattern subtracted and measles removed
The original Fits file is never modified when -savefrm is set.
MODIFICATION HISTORY:
FEB-2005, Paul Hick (UCSD/CASS)
Complete overhaul of Andys version to allow direct processing
from the SMEI data base.
JUN-2005, Paul Hick (UCSD/CASS), V1.02.
nped_min for cam 1 and 2 in mode 2: from 115 to 105
ped_median_excess for cam 1 and 2 in mode 2: from 2 to 4
Added bSaveFrm option
JUL-2005, Paul Hick (UCSD/CASS), V1.03
Changed ped_right_offset_cam(3,1:2) from bad to zero
Fixed bug in cal_name determination. Left-right pedestal offset
in ped_aux(SMEI__PED_RIGHT_OFFSET) cleared for each frame instead
of only when calibration pattern changes.
JUL-2005, Paul Hick (UCSD/CASS), V1.04
Modification in smei_frm_ped. ped_aux(SMEI__PED_RIGHT_OFFSET)
is now updated only by frames that pass the pedestal test on
ped_aux(SMEI__PED_MEAN_REF)+ped_aux(SMEI__PED_MEAN_EXCESS).
There also is a warning printed if ped_mean_diff (difference
between left and right mean pedestal) rises above
ped_aux(SMEI__PED_MEAN_EXCESS). If this happens
ped_aux(SMEI__PED_RIGHT_OFFSET) is not updated, and the pedestal
calculation might get stuck in a bad state.
AUG-2005, Paul Hick (UCSD/CASS), V1.05
smei_frm_read contained a bug that affected the cam3/mode1 frames
only. The frame time was not picked up correctly, and as a result
the onboard factor 2 gain change in Feb 2005 was not compensated
for correctly.
AUG-2005, Paul Hick (UCSD/CASS), V1.06
Changed ndark_min_cam(3,1) from 100 to 450.
Added dark_max_ratio to list of command line arguments.
AUG-2005, Paul Hick (UCSD/CASS), V1.07
In smei_frm_saturated the saturation value for frames where
the onboard flatfield is not enabled (primarily camera 3 mode 1
data) was changed from 65535 to 65533.
SEP-2005, Paul Hick (UCSD/CASS), V2.00
Residual values for squares and center group are now a mean
(instead of a median).
NOV-2005, Paul Hick (UCSD/CASS), V2.01
dark_scale_ratio_cam is now initialized to BadInitFlag for
camera 3. This triggers calculation of the ratio using
the function smei_frm_ratio (called in smei_frm_base).
NOV-2005, Paul Hick (UCSD/CASS), V2.02
dark_scale_ratio_cam is set to BadInitFlag only for mode 1
(mode 0 and 2 are set to one).
dark_scale_fudge_cam is also set to BadInitFlag for mode 1.
This triggers calculation of fudge ratio with smei_frm_c3fudge.
NOV-2005, Paul Hick (UCSD/CASS), V2.03
The fudge scale and offset are now applied whenever a dark
current value is available (even a rejected value), and not
only to dark currents of accepted frames. Note that this affects
camera 3 only (cam 1 and 2 do not have fudge factors).
MAR-2007, Paul Hick (UCSD/CASS), V3.10
Set ped_aux(SMEI__PED_LEFT_SIDE_ONLY) to BadR4 to compensate
for changes to smei_frm_ped.
For camera 3 only after 2005, Doy 159 00 UT, the pedestal is
now derived from the left side (underscan) pedestal columns
only. Note that this also means that the left-side offset for
the pedestal is no longer tracked.
MAR-2007, Paul Hick (UCSD/CASS), V4.00
For camera 3 only a check is made whether the "bad pixel"
mask is in effect. If it is then the calibration pattern with
the mask taken into account is used instead of the regular
mask.
For camera 3 the header entry for the orbital (on-the-fly)
pattern always used to be set to a name based on the orbit
start time for each frame. Now this entry is cleared (if
present) if the mode is not 1, or if the mode is 1 but the
the corresponding orbital pattern file does not exist.
(smei_orb is now responsible for setting this entry).
JUN-2007, Paul Hick (UCSD/CASS), V4.10
Bug fixes to smei_frm_read introduced in V4.00.
For time periods with a "bad pixel" mask onboard
(smei_frm_c3mask_active(0,ctime,-1,cmask)=1)
two errors were made:
- For camera 3, mode 1, the gain change of a factor two was
not applied to frames with the flat_enabled flag off (zero),
i.e. the pedestal was 2x the correct value (and all frames
were rejected as bad).
- For cameras 1 and 2 the headroom 0.75 was not corrected for,
when flat_enabled=1, i.e. the pedestal and dark current
were 0.75 times the correct value.
V4.00 was run for all cameras from 2006_001 to 2007_160.
JUL-2007, Paul Hick (UCSD/CASS)
Modified use of c3mask cmd line argument (used for camera 3
in mode 1 only).
If -c3mask=0 is specified then the regular calibration pattern
(with no "bad-pixel" mask taken into account) is used for all
frames.
If -c3mask=1 is specified then the calibration pattern with
the "bad-pixel" mask taken into account is used. This is only
useful for periods were a "bad-pixel" mask was in effect
(only for these periods does a "bad-pixel" calibration
pattern exist).
If -c3mask=-1 then the program decides which pattern to use
on a frame-by-frame basis (see smei_frm_c3mask_active)
If no explicit pattern is specified (i.e. the pattern from the
frame headers is used then -c3mask=-1 is the default.
If an explicit pattern file is specified on the cmd line, then
only -c3mask=0 or -c3mask=1 are valid. The default is -c3mask=0.
JUL-2007, Paul Hick (UCSD/CASS; pphick@ucsd.edu), V4.11
For camera 2 the pedestal is now calculated only from the
underscan (left-side) columns for frames after 2006_125.
JUN-2008, Paul Hick (UCSD/CASS)
Added -test cmd line argument (no frames written)
Addde -nofudge keyword (suppress fudge factors for dark current)
JUL-2008, Paul Hick (UCSD/CASS), V4.12
Added Fits keyword DARK_AVE for mean of dark current.
(Keyword DARK_CUR contains the fudged median)
JUL-2008, Paul Hick (UCSD/CASS), V4.13
Fudge factors for camera 3 with "bad-pixel" mask active
are now calculated differently (single fudge factor
for each mask).
OCT-2008, Paul Hick (UCSD/CASS), V4.14
Significant changes to smei_frm_c3mask_active to fix some
problems with transitions between masks. Added new mask.
Added cmd line args -ped_median_deficit and -ped_median_excess
NOV-2008, Paul Hick (UCSD/CASS), V4.15
Added cmd line args -ped_mean_ref and -ped_mean_excess.
Especially the default ped_mean_ref is not adequate anymore for
camera 3. The default ped_mean_excess is probably still OK.
NOV-2008, Paul Hick (UCSD/CASS), V5.00
Removed cmd line arg -ped_mean_ref again.
Whenever some estimate for the pedestal is needed this
is now obtained by a call to function smei_frm_ped_mean.
This replaces hardcoded values in ped_mean_ref_cam (copied
to ped_aux(SMEI__PED_MEAN_REF)) and ped_init_cam (copied
to base_aux(SMEI__BAS_PED_INIT+[0,1,2]).
JUN-2011, Paul Hick (UCSD/CASS), V5.01
Added -later_pattern cmd line option to select later pattern.
NOV-2012, Paul Hick (UCSD/CASS; pphick@ucsd.edu), V5.02
Added -twopass option to make two passes on the pedestal
calculation: -twopass=1: make two passes if first pass fails;
-twopass=2: always make two passes.
[Previous]
[Next]
NAME:
smei_cal
PURPOSE:
Determines dark current pattern from weekly closed shutter calibrations.
CALLING SEQUENCE:
program smei_cal
smei_cal [-force -crx -stats -nic]
<pattern> destination=<destination> camera=<camera> mode=<mode>
INPUTS:
SMEI frames from SMEI data base.
OUTPUTS:
The primary output file is a Fits file with name c#cal_YYYY_DOY_hhmmss
in the destination directory, where the date is taken from the middle
frame in the group used to calculate the pattern.
The Fits file contains the mode 0, mode 1 and mode 2 pattern. The mode
0 array is the primary array, with mode 1 and 2 as Fits extensions.
If -stats is set then one line for each frame is written to file
c#cal_YYYY_DOY_hhmmss_stats.dat.
If -force is set then existing pattern files are overwritten. By default
no new patterns are created if the Fits pattern file already exists.
(the pattern is still calculated and is used to process the other keywords).
INCLUDE:
include 'dirspec.h'
include 'openfile.h'
include 'filparts.h'
include 'smei_frm_hdr.h'
include 'smei_frm_layout.h'
include 'smei_frm_basepar.h'
include 'math.h'
include 'smei_cal_version.h'
CALLS: ***
ArrR4Constant, ArrR4Mask, ArrR4SetMinMax, BadI4, BadR4, ForeignArgSet, Int2Str
SMEI_FRM_PED_MEAN, Say, Str2Str, Time2Str, WhatIsR4, WriteI4GRD, bOpenFile, bWriteFrm
cDbl2Str, iFilePath, iFreeLun, iGetFileSpec, iGetLogical [1], iGetLogical [2]
iHideLogical, iOSDeleteFile, iSearch, iSetFileSpec, itrim, smei_Time2Split
smei_cal_build, smei_cal_c3mask, smei_cal_group, smei_foreign, smei_frm_base
smei_frm_clean, smei_frm_get, smei_frm_measle, smei_frm_mode, smei_frm_path
smei_frm_pickup, smei_frm_read, smei_frm_saturated, smei_frm_stats
RESTRICTIONS:
The program has only been tested on Linux. To get it to work on
Windows probably some modifications are needed to the Windows
version of iSearch.
EXAMPLES:
Make pattern files for all patterns defined in $SMEIDB/cal/txt
and make Fits files.
smei_cal $SMEIDB/cal/txt/*.txt
To put Fits pattern files only in directory $SMEIDB/cal
smei_cal $SMEIDB/cal/txt/*.txt -destination=$SMEIDB/cal
PROCEDURE:
The patterns produced are identical to the patterns produced by Andys
original program with two differences:
1. For cameras 1 and 2 Andy did not fill the pattern in the pedestal columns
(13-16, 1269-1272); this version does.
Since for cameras 1 and 2 the pedestal pattern is never used the first
difference does not matter. Only for camera 3 is the pedestal pattern used.
2. Andys program did not use the dark current pixels in the top row on the
right side (row 256, cols 1265-1268) to calculate the dark current, but
did fill in the pattern for three of these pixels (1265-1267). Only in
pixel (1268,256) was the pattern not calculated. This program throws
out all four pixels all the time, so there is no pattern for these pixels.
For use with mode 1 and 2 data the engineering (mode 0) pattern is
binned down by 2x2 and 4x4, respectively. In mode 1 the pattern
in dark current pixels ([629,128] and [630,128] ) will be different;
in mode 2 dark current pixel [317,64] will be different.
After 2005 June 8 (Doy 159) 00:00:00 UT only the left side of the frame
(the underscan region) is used in the pedestal calculation for camera 3.
(At the end of this day Coriolis came on-line again after a month long
mishap with Windsat). This was done to reduce the effect of an increasing
left-right assymetry due to dark-current bleeding in the direction of the
readout and artificially increasing the overscan pedestal values.
MODIFICATION HISTORY:
APR-2004, Andrew Buffington (UCSD/CASS; abuffington@ucsd.edu)
Note that "headroom" and small-scale FF are turned OFF when
camera 3 in 1x1 mode as here...
Another consequence of this is that columns 21 and 1264 are
NOT stamped out as would be the case if the SSFF were imposed.
Thus these have a full amount of pedestal and dark current,
but only an unknown and variable-with-row fraction of sky
between 0.5 and unity. Yuck!
JUN-2004, Paul Hick (UCSD/CASS)
Substantial rewrite to allow direct processing from the SMEI data base.
FEB-2007, Paul Hick (UCSD/CASS)
Modified to take presence of "bad pixel" mask into account for camera 3.
For patterns during times when a "bad pixel" mask is into effect
the pattern Fits file now contains an additional three extensions
with the mask-adjusted pattern for mode 0,1 and 2
(see smei_cal_c3mask).
MAR-2007, Paul Hick (UCSD/CASS)
For camera 3 after 2005_159 the pedestal is now calculated from the
left side (underscan) pedestal columns only.
JUN-2007, Paul Hick (UCSD/CASS)
Recompiled after bugfix in smei_frm_read. The bug did not affect
the calibration patterns, so the recompile does not change anything.
JUN-2007, Paul Hick (UCSD/CASS)
For camera 2 after 2006_125 the pedestal is now calculated from the
left side (underscan) pedestal columns only.
DEC-2007, Paul Hick (UCSD/CASS)
Added some code to prefix directory names to SMEI frames processed
to make the patterns (uses input through keyword -source).
JUN-2008, Paul Hick (UCSD/CASS)
Added cmd line option -test (test mode: no files written)
JUL-2008, Paul Hick (UCSD/CASS)
Both mean-based and median-based dark current are now put
in the Fits header for the calibration pattern
(previously only the median was put in the Fits file)
OCT-2008, Paul Hick (UCSD/CASS)
Added new mask to smei_frm_c3mask_active. Fixed some bugs in
defining transitions between masks.
NOV-2008, Paul Hick (UCSD/CASS), V2.0
Whenever some estimate for the pedestal is needed this
is now obtained by a call to function smei_frm_ped_mean.
This replaces hardcoded values in ped_mean_ref_cam (copied
to ped_aux(SMEI__PED_MEAN_REF)) and ped_init_cam (copied
to base_aux(SMEI__BAS_PED_INIT+[0,1,2]).
APR-2009, Paul Hick (UCSD/CASS; pphick@ucsd.edu), V2.1
Added keyword PED_VAL with the mean pedestal of the frames
used to build the pattern.
OCT-2010, John Clover (UCSD/CASS), V2.11
The left side pedestal columns are now correctly used
for calibration patterns. (Change was made JUN-2007 and
subsequently disappeared.
JUN-2011, Paul Hick (UCSD/CASS; pphick@ucsd.edu), V2.2
Added keyword C3MASK, containing the name of a C3
"bad-pixel" mask, to FTS hdr for cal pattern with
cam3 on-board flatfield mask applied.
[Previous]
[Next]
NAME:
smei_cal_add
PURPOSE:
Accumulutes information for engineering mode pattern calculation
CATEGORY:
ucsd/camera/for/lib
CALLING SEQUENCE:
subroutine smei_cal_add(cut, nx, ny, frame, pattern, count, count_cr)
INPUTS:
cut real threshold for cosmic ray determination
nx integer horizontal frame size
ny integer vertical frame size
frame(nx,ny) real frame data with pedestal already subtracted
pattern(nx,ny) real accumulates pattern data
count (nx,ny) real counts number of frames contributing to each pixel
in the pattern.
!! Count is initialized by caller (smei_cal_build).
count_cr integer counts # pixels excluded because they are suspected
to be cosmic rays.
!! count_cr must be initialized to a negative value
!! to make sure that smei_add_pat is initialized properly.
!! count_cr is set to zero as part of the initialization.
OUTPUTS:
pattern(nx,ny) real updated pattern
count (nx,ny) real updated count data
count_cr integer updated cosmic ray count
CALLS: ***
BadR4, Flt2Str, Int2Str, Say, Str2Str
CALLED BY:
smei_cal_build
INCLUDE:
include 'smei_frm_layout.h'
REMARK:
In Andys original program the 'cut' value used was twice as big as here, but was
multiplied by 0.5 when the cut was applied. The factor 0.5 has been absorbed here
in the value for 'cut'.
PROCEDURE:
The pattern is calculated in pedestal, dark current and covered pixels.
Only pixels that are consistently flagged as bad (probably by smei_frm_clean)
will not receive a pattern value.
Currently (Jun-2004) these are the four leading columns in the eng mode frames
and 8 pixels at the top right of the CCD, for a total of 4*256+8=1032 pixels
with no pattern.
MODIFICATION HISTORY:
JUN-2004, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
[Previous]
[Next]
NAME:
smei_cal_bin
PURPOSE:
Rebin engineering mode frame (mode 0) to
pseudo science=mode frame (mode 1 and 2)
CATEGORY:
camera/for/cal
CALLING SEQUENCE:
subroutine smei_cal_bin(mode,hdr,frame,hdr_,frame_)
INPUTS:
OUTPUTS:
CALLS: ***
ArrR4TimesConstant, ArrR8Copy, Say, Time2Str, smei_frm_c3mask_active, smei_hdr_str
smei_hdr_time
CALLED BY:
smei_cal_build
INCLUDE:
include 'smei_frm_hdr.h'
include 'smei_frm_layout.h'
PROCEDURE:
MODIFICATION HISTORY:
JUN-2008, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
[Previous]
[Next]
NAME:
smei_cal_build
PURPOSE:
Calculates engineering mode pattern from selection of 'closed shutter' data.
CATEGORY:
ucsd/camera/for/lib
CALLING SEQUENCE:
subroutine smei_cal_build(bMask,rmask,nfrm,cfrm,cdest,pattern_cut,
& pattern_ped,pattern,pattern_dark,dark_pixs,ncr_count,ped_aux)
INPUTS:
bMask logical .FALSE.: do not try to apply a "bad pixel" mask
.TRUE. : try to apply a "bad pixel" mask
rmask(*) real onboard mask (used only if bMask=.TRUE.)
cdest(*) character destination for rebinned frames
(see PROCEDURE)
nfrm integer # frames
cfrm(nfrm) character*(*) fully-qualified file names of SMEI data frame
pattern_cut real
ped_aux(*) real
OUTPUTS:
pattern_ped real pattern pedestal
mean of all nfrm pedestals
pattern_dark(2) real pattern dark current
median and mean of all nfrm dark currents
pattern(*) real eng mode frame pattern
dark_pixs(SMEI__DRK_NPIX,nfrm)
real all the individual dark current pixels
CALLS: ***
ArrR4AddConstant, ArrR4DivideByArrR4, ArrR4TimesArrR4, ArrR4Zero, BadR4, Flt2Str
Int2Str, Say, Str2Str, iArrR4ValuePresent, iCheckDirectory, iFilePath, iGetFileSpec
iSetFileSpec, itrim, smei_cal_add, smei_cal_bin, smei_frm_clean, smei_frm_dark
smei_frm_fts, smei_frm_mode, smei_frm_ped, smei_frm_read
CALLED BY:
smei_cal
INCLUDE:
include 'openfile.h'
include 'filparts.h'
include 'smei_frm_layout.h'
include 'smei_frm_basepar.h'
include 'smei_frm_hdr.h'
PROCEDURE:
The pattern is calculated in pedestal, dark current and covered pixels.
Only pixels that are consistently flagged as bad (probably by smei_frm_clean)
will not receive a pattern value.
Currently (Jun-2004) these are the four leading columns in the eng mode frames
and 8 pixels at the top right of the CCD, for a total of 4*256+8=1032 pixels
with no pattern.
A check is made to ensure that all dark current and uncovered pixels are
actually filled with something (i.e. are not returned as zero). Excluded from
this check are four dark current pixels in the top row at the right of the CCD
which are flagged as bad in smei_frm_clean, and will be zero in the pattern
calculated here.
In all dark current output the pedestals have been subtracted already.
If bMask is .TRUE. on input then the "bad pixel" mask (rmask) is applied
to each of the frames in cfrm. The "bad pixel" mask is only active during
certain time periods (see smei_frm_mask) for camera 3 only.
If cDest is not a blank string, it should contain an existing directory
(usually the same directory the calibration patterns are written to).
cDest should contain subdirectories 'mask_out' and 'mask_in'.
If bMask=.FALSE. and 'mask_out' exists the mode 0 frames are rebinned
for all three modes (mode 0: 1x1, mode 1: 2x2 and mode 2: 4x4), and
these 'pseudo frames' are written to subdirectories 'c1','c2','c3'
in 'mask_out', depending on camera). If bMask=.TRUE. and 'mask_in' the frames
go to 'mask_in' instead. The 'mask_out' directory contains frames 'as is'
'mask_in' contains frames with the appropriate "bad-pixel" mask
folded in (i.e. with "bad pixels" that are removed from the real science
mode data blanked out prior to binning). Note that only camera 3 has a
"bad-pixel" mask.
So the directory structure is:
|- c1 (cam 1, mode 0,1,2 pseudo frames
|-- mask_out -|- c2 (cam 2, mode 0,1,2 pseudo frames
| |- c3 (cam 3, mode 0,1,2 pseudo frames
<cDest> --|
|-- mask_in ---- c3 (cam 3, mode 0,1,2 pseudo frames
In these frames header entries related to pedestal and dark current
are set to 0, and can be filled in by running smei_base.
MODIFICATION HISTORY:
JUN-2004, Paul Hick (UCSD/CASS)
FEB-2007, Paul Hick (UCSD/CASS)
Added bMask argument to allow creation of patterns with
the "bad pixel" mask for camera 3 applied.
JUN-2008, Paul Hick (UCSD/CASS)
Added code to write out rebinned "science mode" frames for each
of the frames used to create the calibration pattern.
JUL-2008, Paul Hick (UCSD/CASS)
Changed from function to subroutine. Extra keyword pattern_dark
returns median and mean pattern dark current.
NOV-2008, Paul Hick (UCSD/CASS)
Modified to accomodate new arg to smei_frm_ped
APR-2009, Paul Hick (UCSD/CASS; pphick@ucsd.edu), V2.1
Added keyword PED_VAL with the mean pedestal of the frames
used to build the pattern.
[Previous]
[Next]
NAME:
smei_cal_c3mask
PURPOSE:
Reads bad pixel mask for camera 3
CATEGORY:
gen/for/lib/frm
CALLING SEQUENCE:
logical function smei_cal_c3mask(ipatt,tframe,flat_enabled,mask,tmask)
INPUTS:
ipatt integer 0/1, passed to smei_frm_c3mask_active
tframe character SMEI frame time in format YYYY_DOY_hhmmss
flat_enabled integer nint(hdr(SMEI__HDR_FLAT_ENABLED)) or -1
"flatfield-enabled" flag from SMEI frame header
OUTPUTS:
smei_cal_c3mask logical .TRUE. : bad pixel mask in use for specified time
and flatfield flag (if not -1)
.FALSE.: no bad pixel mask in use for specified time
and flatfield flag (if not -1)
mask(*) real bad pixel mask
Mask has full resolution of 1272x256 and
contains values 0 and 1.
If no bad pixel mask is in effect than all values
in the mask are set to 1.
tmask character*(SMEI__UT_FORMAT_LEN)
smei_cal_c3mask=.TRUE. : name of C3 "bad-pixel" mask
smei_cal_c3mask=.FALSE.: blank string
CALLS: ***
ArrR4Constant, Int2Str, Say, Str2Str, bOpenFile, cInt2Str, iFilePath, iFreeLun
smei_frm_c3mask_active
CALLED BY:
smei_cal
INCLUDE:
include 'filparts.h'
include 'dirspec.h'
include 'openfile.h'
include 'smei_frm_layout.h'
PROCEDURE:
The test for whether or not a "bad pixel" needs to be read is
done by smei_frm_c3mask_active.
A mask is applied only for camera 3 in mode 1 (2x2 binned). The mask is
multiplied with the readout onboard, EXCEPT THAT the mask is NOT APPLIED
when a whole 2x2 group of mask elements is zero. In this case the
the usual 2x2 average is returned.
Therefore, if a 2x2 group of elements in the mask read from file is set
to zero (flagged as "bad") then the 4 pixels in this group are set back
to one (set to "good").
MODIFICATION HISTORY:
FEB-2007, Paul Hick (UCSD/CASS)
JUN-2011, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
Added new argument, tmask, to return name of C3 "bad-pixel" mask.
[Previous]
[Next]
NAME:
smei_cal_get
PURPOSE:
Get closed shutter calibration pattern.
CALLING SEQUENCE:
subroutine smei_cal_get(cFile,ipick,icam,mode,mask,time,
& cpattern,pattern,pattern_dark,bNew,version)
INPUTS:
cFile*(*) character fully-qualified file name of pattern file
(must be a .grd file, .fts or .fts.gz file).
If left empty or set to SMEIDB? then a
calibration pattern is selected from
$SMEIDB/cal (a Fits file) based
on the fourth input argument (time).
ipick integer 0: pick earlier pattern for mode 1,2
and nearest pattern for mode 0
1: always pick nearest pattern
2: pick later pattern for mode 1,2 and
nearest pattern for mode 0
camera integer camera number (1,2,3)
mode integer camera mode (0,1,2)
mask integer C3 mask applied or not (0=No,1=Yes)
time(2) integer time used for pattern selection.
For mode 0 the pattern closest to 'time' is returned
For mode 1 and 2 the last pattern preceeding 'time'
is returned.
OUTPUTS:
cpattern*(*) character file name of calibration pattern
pattern(*) real calibration pattern
pattern_dark real dark current in calibration pattern.
bNew logical .TRUE. if smei_cal_read was called to read new
pattern; .FALSE. if not.
version double precision (Only if bNew = .TRUE.)
version number of smei_cal program that wrote the
the calibration pattern. If bNew=.FALSE. then version=0.
I.e. the version number is returned only if
smei_cal_read is called.
CALLED BY:
smei_base, smei_orb, smei_skyd_fts, smei_skyd_init, smei_skyd_make, smei_skyd_sky
INCLUDE:
include 'filparts.h'
include 'dirspec.h'
include 'smei_frm_layout.h'
RESTRICTIONS:
smei_cal_init() needs to be called first.
CALLS: ***
Int2Str, Say, Str2Str, Time2Delta, Time2Differ, cInt2Str, cTime2Str, iFilePath, iFreeLun
iGetFileSpec, iGetLun, iSearch, iSetFileSpec, itrim, smei_Time2Split, smei_cal_read
smei_cal_version
PROCEDURE:
The first nX * nY elements of pattern will be filled where
nX = 1272, 636 or 318 and nY = 256, 128, 64 for mode 0,1 and
2, respectively.
MODIFICATION HISTORY:
DEC-2004, Paul Hick (UCSD/CASS)
JUL-2005, Paul Hick (UCSD/CASS)
Fixed bug in pattern selection for mode 0 (would fail if
frame time was later than last pattern).
SEP-2005, Paul Hick (UCSD/CASS)
Added bNew
MAR-2007, Paul Hick (UCSD/CASS)
Added argument 'mask' to access patterns with c3 "bad pixel"
mask applied.
JAN-2008, Paul Hick (UCSD/CASS)
Added argument 'version'
JUL-2008, Paul Hick (UCSD/CASS)
Added argument ipick
JUN-2011, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
Added ipick=2 option to pick later pattern.
[Previous]
[Next]
NAME:
smei_cal_group
PURPOSE:
Processes the content of the list file with information about
all groups of closed shutter frames.
CALLING SEQUENCE:
integer function smei_cal_group(cList, icam, TBeg, TEnd, cframes, cframeref, bTfloat)
INPUTS:
cList*(*) character name of ASCII file with frame names
OUTPUTS:
icam integer camera number (1,2,3)
TBeg(2) integer start time of 'closed shutter' data
TEnd(2) integer end time of 'closed shutter' data
cframes(smei_cal_group)
character list of frame names to be used to
calculate the shutter.
cframeref*(*) character base name for all pattern-related output files.
cframeref contains only a file (no directory, no type)
bTfloat logical set to .TRUE. if the patterns were selected near
the minimum (camera 1,2) or maximum (3) of the CCD
temperature curve.
(!!!! this is only correct for camera 3 and for
cameras 1 and 2 for the patterns after approximately
doy 100 in 2004.)
smei_cal_group integer # frames in array cframes
CALLED BY:
smei_cal
INCLUDE:
include 'filparts.h'
include 'openfile.h'
CALLS: ***
LocFirst, LocFirstLen, Say, bOpenFile, iFreeLun, iGetFileSpec, iSetFileSpec, itrim
smei_Time2Split
PROCEDURE:
Each closed shutter calibration is characterized in a small ascii file
containing a group 2+N frame names (currently N=10).
Frames 1 and 2 bracket the 'closed shutter' data;
the following group on N frames is used to determine the pattern.
MODIFICATION HISTORY:
JUN-2004, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
[Previous]
[Next]
NAME:
smei_cal_init
PURPOSE:
Initializes data base of calibration patterns for use
with smei_get_cal.
CALLING SEQUENCE:
entry smei_cal_init()
CALLS: ***
Int2Str, Say, Str2Str, Time2Delta, Time2Differ, cInt2Str, cTime2Str, iFilePath, iFreeLun
iGetFileSpec, iGetLun, iSearch, iSetFileSpec, itrim, smei_Time2Split, smei_cal_read
smei_cal_version
CALLED BY:
smei_base, smei_orb, smei_skyd
MODIFICATION HISTORY:
FEB-2005, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
[Previous]
[Next]
NAME:
smei_cal_read
PURPOSE:
Read closed shutter calibration pattern file
CATEGORY:
ucsd/camera/for/lib
CALLING SEQUENCE:
subroutine smei_cal_read(cFile, mode, mask, pattern_dark, nx, ny, pattern)
INPUTS:
cFile*(*) character fully qualified Fits pattern file name
mode integer camera mode (0,1,2)
mask integer C3 mask applied or not (0=No,1=Yes)
OUTPUTS:
pattern_dark real dark current in pattern
pattern(*) real engineering mode (1272x256) pattern array
nfrm integer # frames used to calculate the pattern
cfrm(nfrm) character names of frames used to calculate the pattern
TBeg(2) integer Begin time of closed shutter calibration data
TEnd(2) integer End time of closed shutter calibration data
All engineering mode frames between TBeg and TEnd
are used for the performance test.
ncr_count integer cosmic ray count (from smei_cal_add)
CALLED BY:
smei_cal_get, smei_cal_init
INCLUDE:
include 'filparts.h'
include 'smei_frm_layout.h'
include 'ftspar.h'
CALLS: ***
FTCLOS, FTGISZ, FTGKNS, FTGKYD, FTGKYE, FTGKYJ, FTGKYL, FTGKYS, FTGPVE, FTMAHD, FTNOPN
Int2Str, Say, Str2Str, cInt2Str, iFreeLun, iGetFileSpec, iGetLun, iSetFileSpec, say_fts
smei_Time2Split
MODIFICATION HISTORY:
JUN-2004, Paul Hick (UCSD/CASS)
MAR-2007, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
Added argument 'mask' to deal with patterns with c3 "bad pixel"
mask applied.
[Previous]
[Next]
NAME:
smei_cal_time
PURPOSE:
Time of calibration pattern.
CATEGORY:
ucsd/camera/for/lib
CALLING SEQUENCE:
entry smei_orb_cal_time(TTime)
INPUTS:
(none)
OUTPUTS:
TTime(2) integer time of calibration pattern
CALLS:
TimeSplit
PROCEDURE:
Entry point in smei_orb_read.
MODIFICATION HISTORY:
JUN-2004, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
[Previous]
[Next]
NAME:
smei_cal_version
PURPOSE:
Stores version number for program smei_cal
(which makes the "shutter-closed" calibration patterns.
INCLUDED BY:
smei_cal, smei_cal_write
MODIFICATION HISTORY:
OCT-2008, Paul Hick (UCSD/CASS) V1.04
New mask added to smei_frm_c3mask_active
APR-2009, Paul Hick (UCSD/CASS), v. 2.1
Added keyword PED_VAL with the mean pedestal of the frames
used to build the pattern.
OCT-2010, John Clover (UCSD/CASS), V2.11
Changed version slightly to reflect the left column
JUN-2011, Paul Hick (UCSD/CASS; pphick@ucsd.edu), V2.2
Added keyword C3MASK to Fts hdr for cal pattern with
cam3 on-board mask applied.
[Previous]
[Next]
NAME:
smei_cal_write
PURPOSE:
Write closed shutter calibration pattern file
CATEGORY:
ucsd/camera/for/lib
CALLING SEQUENCE:
subroutine smei_cal_write(bTestMode,bAppend,cFile,bTfloat,pattern_ped,pattern_dark,pattern,nfrm,cfrm,TBeg,TEnd,ncr_count,cmask)
INPUTS:
bTestMode logical .TRUE.: no Fits file created/modified
.FALSE.: Fits file created/modified
bAppend logical .FALSE.: create new Fits file
.TRUE. : append to existing Fits file
cFile*(*) character fully qualified name with type missing
bTfloat logical .TRUE. if pattern was based on frames near temperature
minimum (cam 1,2) or maximum (cam 3).
pattern_ped real pedestal in pattern
pattern_dark(2) real dark current in pattern (median and mean)
pattern(*) real engineering mode (1272x256) pattern array
nfrm integer # frames used to calculate the pattern
cfrm(nfrm) character names of frames used to calculate the pattern
TBeg(2) integer Begin time of closed shutter calibration data
TEnd(2) integer End time of closed shutter calibration data
All engineering mode frames between TBeg and TEnd
are used for the performance test.
ncr_count integer cosmic ray count (from smei_cal_add)
cmask character*(SMEI__UT_FORMAT_LEN
name of C3 "bad-pixel" mask or blank string.
If not a blank string it is added to the FTS
header as keyword C3MASK.
OUTPUTS:
CALLS:
ArrR4Copy, ArrR4Mask, ArrR4Zero, BadR4, FTCLOS, FTCRHD, FTINIT, FTPHPR, FTPKNS, FTPKYE
FTPKYJ, FTPKYL, FTPKYS, FTPPRE, Flt2Str, Int2Str, Say, Time2Str, WriteR4GRD, bOpenFile
iFilePath, iFreeLun, iGetFileSpec, iGetLun, iOSSpawnCmd, iSetFileSpec, itrim, say_fts
INCLUDE:
include 'smei_frm_layout.h'
include 'ftspar.h'
include 'filparts.h'
include 'openfile.h'
include 'smei_cal_version.h'
PROCEDURE:
How many bad values do we expect????
MODIFICATION HISTORY:
JUN-2004, Paul Hick (UCSD/CASS)
FEB-2007, Paul Hick (UCSD/CASS)
Added bAppend argument to be able to append patterns with
"bad pixel" mask applied.
DEC-2007, Paul Hick (UCSD/CASS)
Added DATE keyword with creation date for file
JAN-2008, Paul Hick (UCSD/CASS), v. 1.01
Added keyword SMEI_CAL with software version number
JUN-2008, Paul Hick (UCSD/CASS), v. 1.02
Added argument bTestMode
Added keyword TIME (same time as in pattern name)
Fixed bug: keyword NAME was not filled correctly.
JUL-2008, Paul Hick (UCSD/CASS), v. 1.03
Added keyword DARK_AVE with the mean dark current
(DARK_VAL contains the median)
APR-2009, Paul Hick (UCSD/CASS; pphick@ucsd.edu), v. 2.1
Added keyword PED_VAL with the mean pedestal of the frames
used to build the pattern.
JUN-2011, Paul Hick (UCSD/CASS; pphick@ucsd.edu), v. 2.2
Added input argument cmask, containing the name of the
C3 "bad-pixel" mask used (or blank string if it isn't
used). It is added to the header for the cal pattern
with mask applied as keyword C3MASK.
[Previous]
[Next]
NAME:
smei_cam2ccd
PURPOSE:
Convert sky coordinates in camera fram to CCD coordinates
CALLING SEQUENCE:
entry smei_cam2ccd(icam,r0,x,y,rx,ry,rz,tx,ty)
INPUTS:
icam integer camera id (1,2,3)
r0 double precision distance center of fov curvature to optical axis (in pixels)
rx double precision x-component of unit vector
ry double precision y-component of unit vector
rz double precision z-component of unit vector
OUTPUTS:
x double precision hor distance to center of fov curvature (in pixels)
y double precision vert distance to center of fov curvature (in pixels)
tx double precision theta-x = arcsin(rx)
ty double precision theta-y = arcsin(ry)
CALLS: ***
BadR8, datan2d, dcosd, dsind
RESTRICTIONS:
The conversion is only performed for sensible (rx,ry,rz), i.e. for unit
vectors that project close to the field of view.
PROCEDURE:
(rx,ry,rz) is a unit vector representing the location
on the sky of (x,y) on the CCD, i.e. rx,ry,rz are the
direction cosines.
Quadratic coefficients from Andys July 2001 memo. In addition some
ad-hoc stretching of tx and ty is done
MODIFICATION HISTORY:
JAN-2004, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
[Previous]
[Next]
NAME:
smei_ccd2cam
PURPOSE:
Convert CCD coordinates to sky coordinates
CALLING SEQUENCE:
subroutine smei_ccd2cam(icam,r0,x,y,rx,ry,rz,tx,ty)
INPUTS:
icam integer camera id (1,2,3)
r0 double precision distance center of fov curvature to optical axis (in pixels)
x double precision hor distance to center of fov curvature (in pixels)
y double precision vert distance to center of fov curvature (in pixels)
OUTPUTS:
rx double precision x-component of unit vector
ry double precision y-component of unit vector
rz double precision z-component of unit vector (always positive)
tx double precision theta-x = arcsin(rx)
ty double precision theta-y = arcsin(ry)
CALLS: ***
BadR8, datan2d, dcosd, dsind
RESTRICTIONS:
The input values for x,y need to be sensible, i.e. not too far
outside the field of view.
PROCEDURE:
(rx,ry,rz) is a unit vector representing the location
on the sky of (x,y) on the CCD, i.e. rx,ry,rz are the
direction cosines.
Quadratic coefficients from Andys July 2001 memo. In addition some
ad-hoc stretching of tx and ty is done
MODIFICATION HISTORY:
NOV-2004, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
[Previous]
[Next]
NAME:
smei_eclipse
PURPOSE:
Check whether SMEI is seeing a solar eclipse
(by Moon) or is in Earth shadow.
CATEGORY:
gen/for/lib
CALLING SEQUENCE:
logical function smei_eclipse(tt,id,fraction)
INPUTS:
tt(2) integer UT time
id integer 10: solar eclipse by Moon
3: solar eclipse by Earth
(i.e. in Earth shadow)
OUTPUTS:
smei_eclipse
logical .TRUE.: eclipse in progress
fraction real fraction of solar disk covered.
For eclipses by Moon the fraction
will be larger than one for a total.
For Earth shadow the fraction is
never larger than one.
CALLS: ***
Say, Time2jpl_eph, Time2smei_eph
CALLED BY:
smei_frm_fts_eph
IMPLICIT:
implicit double precision (A-H,O-Z)
INCLUDE:
include 'sun.h'
include 'planet.h'
include 'math.h'
MODIFICATION HISTORY:
FEB-2005, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
[Previous]
[Next]
NAME:
smei_FitPlane
PURPOSE:
Solves for a least-squares planar fit through the 8 z-values
surrounding [0,0], then reduces all 9 z values relative to
the plane, and returns with the reduced values.
CATEGORY:
gen/for/lib
CALLING SEQUENCE:
subroutine smei_FitPlane(z,dz,z0,a,b,sumzz)
INPUTS:
z(-1:1,-1:1) real 3x3 array of fnc values
OUTPUTS:
dz(-1:1,-1:1) real 3x3 array of residuals after subtracting
planar fit
z0 real planar fit value at center pixel
a,b real slopes in x and y direction
(i.e. the planar fit is f=z0+a*i+b*j
with i=-1,0,1, j=-1,0,1)
sumzz real sum of square of residual of 8 pixels
on outside (i.e. omitting center pixel).
CALLED BY:
smei_frm_measle, smei_skyd_fts, smei_skyd_init, smei_skyd_make, smei_skyd_sky
MODIFICATION HISTORY:
JUN-2004, Andy Buffington (UCSD/CASS; abuffington@ucsd.edu)
[Previous]
[Next]
NAME:
smei_foreign
PURPOSE:
Process command line arguments
CALLING SEQUENCE:
subroutine smei_foreign(id,cList,cBase,cDest,min_orbit,beg_orbit,end_orbit,forbit,icam,mode,cArg)
INPUTS:
(from command line)
id integer 1: cal_pattern (calibration 'closed shutter' patterns)
2: orb_pattern (on-the-fly orbital patterns)
3: smei_base (all data using patterns; CRX program)
4: smei_htm
OPTIONAL INPUTS:
<pattern_text_template>
destination=<destination>
begin=<beg_time>
orbits=<orbits>
camera=<camera>
mode=<mode>
OUTPUTS:
cList*(*) character extracted from <pattern_text_template>
where <pattern_text_template> is the fully-qualified
file name of the ASCII file containing
the information defining each of the
'closed shutter' data.
Remember to escape any wildcard chars in
<pattern_text_file> to avoid wildcard expansion
at the command prompt.
cBase*(*) character source directory
cDest*(*) character extracted from
-destination=<destination>
where <destination> is the name of an existing
directory where to write the output file.
If not specified than $TUB is used.
min_orbit integer extracted from
-minimum_orbit=<min_orbit>
-minimum_orbit=<YYYY_DOY_hhmmss>
orbit to be used for calculating the mimimum pattern
in orb_pattern. If a time is specified then the orbit
with the closest start time is used.
If absent then the first orbit starting after
the time from the closed shutter pattern is used.
beg_orbit integer extracted from
-start_time=<beg_orbit>
-start_time=<YYYY_DOY_hhmmss>
The first orbit for which a difference orbital pattern
is calculated. If a time is specified then the orbit
with the closest start time is used.
If absent then the first orbit starting after
the time from the closest shutter pattern is used.
end_orbit integer extracted from
-stop_time=<end_orbit>
-stop_time=<YYYY_DOY_hhmmss>
The first orbit for which a minimum orbital pattern
is calculated. If a time is specified then the orbit
with the closest start time is used.
If omitted all orbits up to the time of the
closed shutter pattern following the one
specified in cList are processed.
norbit integer extracted from
-orbits=<orbits>
Alternative to stop_time: # orbits processed starting
at beg_orbit.
forbit(2) double precision
(only accessed if id=2, i.e. for smei_orb)
extracted from
-lowfraction=<lowfraction>
-highfraction=<highfraction>
two fractions of one defining the part of the orbit
used for the orbital minimum and difference patterns.
icam integer extracted from -camera=<camera>
camera number (default: 0)
mode integer extracted from -mode=<mode>
mode number (default: -1)
CALLED BY:
smei_base, smei_cal, smei_orb, smei_skyd
INCLUDE:
include 'dirspec.h'
include 'filparts.h'
CALLS: ***
BadI4, ForeignArg, ForeignArgSet, ForeignI4Arg, ForeignR8Arg, ForeignStrArg
SMEI_FOREIGN_ORBIT_TIME, Say, Time2Differ, bOSFindClose, iCheckDirectory
iFilePath, iGetFileSpec, iGetLogical [1], iGetLogical [2], iSearch, iSetFileSpec
itrim, lowercase, smei_Time2Split, smei_orbit2, smei_orbit_time2
MODIFICATION HISTORY:
JUN-2011, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
Bug fixes: checked for presence of -digsource and -digdestination
before adding them to cArg to avoid program abort because of
"keyword abbreviation not unique" condition.
[Previous]
[Next]
NAME:
smei_frm_base
PURPOSE:
Calculates pedestal and dark current
CATEGORY:
ucsd/camera/for/lib
CALLING SEQUENCE:
logical function smei_frm_base(cframe,nx,ny,frame,pattern,
& nped,ped_val,ndark,dark_val,dark_pixs,
& ped_aux,dark_aux,base_aux)
INPUTS:
cframe character*(*) fully-qualified file name of SMEI data frame
(only used to format messages;
contains time and camera number)
nx integer horizontal frame size
ny integer vertical frame size
frame (nx,ny) real frame data (usually after running it through
smei_frm_clean)
pattern(nx,ny) real dark current pattern
ped_aux(*) real passed to smei_frm_ped
Two values of ped_aux returned by smei_frm_ped
are used here:
ped_aux(SMEI__PED_VERY_LOW) (to reject frame)
ped_aux(SMEI__PED_NAIVE_MEAN) (message only)
dark_aux(*) real passed to smei_frm_dark
If a valid pedestal is returned by smei_frm_ped
then two values in dark_aux are set here before
passing it to smei_frm_dark:
dark_aux(SMEI__DRK_PEDESTAL)
pedestal value returned by smei_frm_ped
dark_aux(SMEI__DRK_RATIO)
dark current ratio of frame and pattern
base_aux(*) real base_aux(SMEI__BAS_DARK_GUESS)
guess at dark current (with pedestal subtracted)
for this frame (usually the dark current from a
previous frame).
If set to bad, then the naive mean dark current
of the frame is used (without using the pattern).
base_aux(SMEI__BAS_PATTERN_DARK)
dark current of pattern.
Used with base_aux(SMEI__BAS_DARK_GUESS) to obtain
the dark current ratio needed by smei_frm_dark.
base_aux(SMEI__BAS_DARK_MAX_RATIO )
base_aux(SMEI__BAS_DARK_SCALE_RATIO)
Used to constrain the dark current ratio fed to
smei_frm_dark, but only if the dark current guess
base_aux(SMEI__BAS_DARK_GUESS) is bad.
base_aux(SMEI__BAS_NPED_MIN)
base_aux(SMEI__BAS_NDARK_MIN)
threshold on number of pixels contributing to
pedestal and dark current respectively.
Frames are rejected if less pixels than this
contribute.
base_aux(SMEI__BAS_NPED_BAD)
needs to be initialized to a negative number
by caller. Other parameters (including this one)
are initialized internally as a result.
OUTPUTS:
smei_frm_base logical .TRUE. if pedestal and dark current are OK
.FALSE. if pedestal and/or dark current are rejected
Note that, if smei_frm_base = .FALSE., the rejected
values are still returned.
nped integer # pixels contributing to pedestal
ped_val real pedestal
ndark integer # pixels contributing to dark current
dark_val real dark current
ped_aux(*) real as modified by smei_frm_ped
base_aux(*) real base_aux(SMEI__BAS_NPED_BAD)
updated counter for # frames rejected because
pedestal exceeded ped_threshold
base_aux(SMEI__BAS_NBAD)
updated counter for # frames rejected because
not enough pixels contributed to the pedestal,
or because the dark current was bad.
dark_pixs(*) real dark current pixels as returned from smei_frm_dark,
or all set to bad if the frame is rejected here.
CALLS: ***
ArrR4Bad, BadR4, Flt2Str, Int2Str, Say, Str2Str, cFlt2Str, iGetFileSpec, iHideLogical
iSetFileSpec, smei_Time2Split, smei_frm_dark, smei_frm_mode, smei_frm_ped
smei_frm_ped_guess, smei_frm_ratio
CALLED BY:
smei_base, smei_cal
INCLUDE:
include 'filparts.h'
include 'smei_frm_layout.h'
include 'smei_frm_basepar.h'
PROCEDURE:
1. Calculate pedestal with smei_frm_ped (using values in ped_aux)
2. If pedestal is bad, then reject frame and return .FALSE.
3. If pedestal is good, then store good pedestal in dark_aux.
4. If no guess for dark current is available, calculate it internally
(by calling smei_frm_dark without using pattern)
5. Store ratio of dark currents of frame and pattern in dark_aux.
6. Calculate dark current with smei_frm_dark (using values in dark_aux).
This time make smei_frm_dark use the pattern.
7. Test pedestal and dark current.
The test mainly ensures that enough pixels contribute to pedestal
and dark current calculation.
8. If the frame is rejected then return .FALSE.
(a recovery attempt is made if more than 12 consecutive frames
are rejected this way).
MODIFICATION HISTORY:
DEC-2004, Paul Hick (UCSD/CASS)
NOV-2008, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
Modified to accomodate new arg in smei_frm_ped call.
Pedestal initialization values stored in
base_aux(SMEI__BAS_PED_INIT+[0,1,2]) are not used anymore.
Instead the value returned by smei_frm_ped_guess is used.
[Previous]
[Next]
NAME:
smei_frm_basepar
PURPOSE:
Include file for pedestal and dark current routines
CATEGORY:
gen/for/h
CALLING SEQUENCE:
include 'smei_frm_basepar.h'
INCLUDED BY:
smei_base, smei_cal, smei_cal_build, smei_frm_base, smei_frm_dark, smei_frm_ped
PROCEDURE:
Note that the prefixes SMEI__PED and SMEI__DRK
are also used in smei__frm_layout.h. Make sure there
is no conflict.
MODIFICATION HISTORY:
OCT-2002, Paul Hick (UCSD/CASS)
FEB-2007, Paul Hick (UCSD/CASS)
Added SMEI__PED_LEFT_SIDE_ONLY
JUL-2008, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
Added SMEI__DRK_MEAN and SMEI__DRK_MEDIAN
(filled in smei_frm_dark)
[Previous]
[Next]
NAME:
smei_frm_c3fudge
PURPOSE:
Set dark current fudge ratio for camera 3, mode 1
CALLING SEQUENCE:
function smei_frm_c3fudge(tt,c3mask)
INPUTS:
tt integer(2) SMEI frame time
c3mask integer 0/1: onboard flatfield off/on
CALLED BY:
smei_base
INCLUDE:
include 'smei_frm_layout.h'
CALLS: ***
Say, Time2DHMS, Time2Day, Time2Delta, Time2Str, Time2YMD, cFlt2Str, cTime2Str
smei_frm_c3mask_active
PROCEDURE:
c3mask=0:
The dark current fudge ratio is a function of time, and
is determined from a fit to a function
f(t) = 1-exp(-(t-b)/a)
where t is the number of days since 2003/04/15 0 UT
The fit is done by the IDL procedure smei_frm_darkratio.pro
c3mask=1:
The fudge factor depends on which "bad-pixel" mask is active.
The actual fudge factor is returned by smei_frm_c3mask_active
RESTRICTIONS:
The origin t0 (currently 2003/04/15 0 UT) MUST match the
origin in the IDL procedure!!.
MODIFICATION HISTORY:
JUL-2008, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
Extracted from smei_frm_ratio
[Previous]
[Next]
NAME:
smei_frm_c3mask_active
PURPOSE:
Check whether camera 3 mask is active at specified time
CATEGORY:
gen/for/lib/frm
CALLING SEQUENCE:
integer function smei_frm_c3mask_active(ipatt,tframe,flat_enabled,cmask,fudge)
INPUTS:
ipatt integer 0: use exact range of "bad-pixel" mask periods
1: use extended range of "bad-pixel" mask periods
for use by smei_cal
tframe character*(*) SMEI frame time in format YYYY_DOY_hhmmss
flat_enabled integer nint(hdr(SMEI__HDR_FLAT_ENABLED)) or -1
if set to -1 this argument is ignored
if set to the "flat_enabled" flag from a
SMEI frame then this flag is tested in
addition to the time.
OUTPUTS:
smei_frm_c3mask_active
integer 1: bad pixel mask in use for specified time
0: no bad pixel mask in use for specified time
cmask character*(*) mask time in format YYYY_DOY_hhmmss
This is used in the construction of the file
name for the mask.
cmask = ' ' if smei_frm_c3mask_active returns 0
fudge real fudge factor for mask
CALLED BY:
smei_base, smei_cal_bin, smei_cal_c3mask, smei_frm_c3fudge, smei_frm_read
smei_frm_read_get_sdark, smei_orb, smei_skyd_fts, smei_skyd_init, smei_skyd_make
smei_skyd_sky
INCLUDE:
include 'smei_frm_layout.h'
PROCEDURE:
A camera 3 "bad pixel" mask is in effect onboard during specific
periods, and since it is applied as a "flatfield" it is only
used if the "flatfield-enabled" flag is set in a SMEI frame.
The time periods are hardcoded in this routine.
If flat_enabled = -1 then only the time 'tframe' is checked:
if the time is inside one of the time periods then
smei_frm_c3mask_active = 1 is returned. Otherwise 0 is returned.
(this is used in smei_cal).
If flat_enabled = 0 or 1 then the flatfield flag is tested also:
If flat_enabled = 0 then always smei_frm_c3mask_active=0 is
returned (the mask is present, but is not applied)
If flat_enabled = 1 then smei_frm_c3mask_active is 1 only if the
time 'tframe' is inside one of the "bad pixel mask" periods
(the mask is present and is applied).
If a new mask is added to this routine than all SMEI Fortran
programs need to be recompiled. This includes smei_base,
smei_cal, smei_orb and smei_skyd.
Modification 2008/10/09: transitions between masks was changed
considerably. A number of patterns were recreated:
2006_038_085451 removed "mask-in" pattern
2006_053_044615 ,,
2006_134_114227 ,,
2006_256_042123 ,,
2007_101_044631 different mask for "mask-in" pattern
==================================
2007_136_044747 - 2007_250_044827
total of 17 patterns: removed "mask-in" pattern
==================================
2008_044_044547 removed "mask-in" pattern
2008_051_034355 removed "mask-in" pattern
==================================
2008_156_040215 - 2008_240_043351
total of 13 patterns: removed "mask-in" pattern
MODIFICATION HISTORY:
MAR-2007, Paul Hick (UCSD/CASS)
APR-2007, Paul Hick (UCSD/CASS)
Added argument ipatt.
NOV-2007, Paul Hick (UCSD/CASS)
Added mask 2007_237
JUL-2008, Paul Hick (UCSD/CASS)
Added mask 2008_023
OCT-2008, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
Added mask 2008_226
OCT-2009, John Clover (UCSD/CASS; jclover@ucsd.edu)
Added mask 2009_260
APR-2010, John Clover (UCSD/CASS)
Added mask 2010_098
OCT-2010, John Clover (UCSD/CASS)
Added mask 2010_259
MAR-2011, John Clover (UCSD/CASS)
Added mask 2011_038
[Previous]
[Next]
NAME:
smei_frm_clean
PURPOSE:
Massages SMEI data frame for further processing
CATEGORY:
gen/for/lib
CALLING SEQUENCE:
integer function smei_frm_clean(nX, nY, frm1, frm2)
INPUTS:
nX integer horizontal frame size
nY integer vertical frame size
frm1(nX,nY) real frame data (from smei_frm_read)
OUTPUTS:
frm2(nX,nY) real massaged data with some
pixels flagged as bad
smei_frm_clean integer # pixels flagged as bad
This should be 8/nbin
In full-frame eng mode (no ROI applied)
this will be 4*256+8 (4 leading columns
of zeros).
CALLS: ***
ArrR4Copy, BadR4, smei_frm_mode
CALLED BY:
smei_base, smei_cal, smei_cal_build, smei_orb
INCLUDE:
include 'smei_frm_layout.h'
include 'smei_frm_hdr.h'
PROCEDURE:
> Pixels with readout of zero ADU are set to bad
This primarily flags the first 4 columns for full-frame eng mode
frames (which contain 4 columns of zero at the start)
> 8 pixels in top row at right side of frame. 4 dark current
and 4 pedestal pixels are set to bad. These sometimes contain
funny values like 0 of 512.
MODIFICATION HISTORY:
JUN-2004, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
[Previous]
[Next]
NAME:
smei_frm_dark
PURPOSE:
Calculates dark current for SMEI data frame
CATEGORY:
ucsd/camera/for/lib
CALLING SEQUENCE:
integer function smei_frm_dark(bMedian, nx, ny, frame, pattern, dark_val, dark_pixs, dark_aux)
INPUTS:
bMedian logical .TRUE. : return median
.FALSE.: return mean
nx integer horizontal frame size
ny integer vertical frame size
frame(nx,ny) real frame data (after massaging by smei_frm_clean)
pattern(nx,ny) real dark current pattern
(not accessed if dark_aux(SMEI__DRK_RATIO) is bad)
dark_aux(*) real dark_aux(SMEI__DRK_PEDESTAL)
pedestal (return value of smei_frm_ped)
dark_aux(SMEI__DRK_HEADROOM)
used in median calculation of dark current
dark_aux(SMEI__DRK_RATIO)
ratio of dark current in frame and dark current
in pattern. If set bad, then the pattern array is
not used. The caller sets the ratio by using some
estimate for the dark current in the frame.
dark_aux(SMEI__DRK_CUT)
threshold above pedestal used to reject dark
current pedestal.
(not accessed if dark_aux(SMEI__DRK_RATIO) is bad)
dark_aux(SMEI__DRK_POWER)
not used (yet?)
OUTPUTS:
smei_frm_dark real # pixels contributing to dark current
dark_val real dark current value (with pedestal subtracted)
if dark_val is bad then smei_frm_dark=0 and v.v.
dark_pixs(*) real all dark current pixel values (with pedestal subtracted)
used to calculate dark_val. If the pattern was
used than 'cosmic ray' pixels were flagged as bad.
dark_aux(*) real three entries
dark_aux(SMEI__DRK_MEAN ) mean-based dark current
dark_aux(SMEI__DRK_MEDIAN) median-based dark current
dark_aux(SMEI__DRK_STDEV ) standard deviation of dark_val
CALLED BY:
smei_cal_build, smei_frm_base
INCLUDE:
include 'smei_frm_layout.h'
include 'smei_frm_basepar.h'
CALLS: ***
ArrR4AddConstant, ArrR4Mean, ArrR4Median, ArrR4Stdev, BadR4, smei_frm_pickup
RESTRICTIONS:
The values in the pattern (when used) should all be valid,
i.e. no BadR4() values at least for those pixels in the
input frame which are expected to contain valid data.
SEE ALSO:
smei_frm_clean, smei_frm_ped
PROCEDURE:
Only the dark current values in the frame are accessed (4 columns left and right
in engineering mode).
If dark_aux(SMEI__DRK_RATIO) is bad then the return value 'dark_val' is the median
or the mean (depending on setting of bMedian) of the dark current pixels, with the
pedestal value in dark_aux(SMEI__DRK_PEDESTAL) subtracted.
If the pattern and dark ratio are available (dark_aux(SMEI__DRK_RATIO) is NOT bad)
then the best estimate of the expected dark current is
dark_aux(SMEI__DRK_PEDESTAL)+dark_aux(SMEI__DRK_RATIO)*pattern
The threshold dark_aux(SMEI__DRK_CUT) is used to detect spikes ('cosmic rays'):
by rejected dark current pixels with values above
dark_aux(SMEI__DRK_PEDESTAL)+dark_aux(SMEI__DRK_RATIO)*pattern+dark_aux(SMEI__DRK_CUT).
The median (or mean) is then calculated after the spikes have been flagged as bad.
Note that the pattern is multiplied with the dark ratio, and NOT with some power of the
dark ratio as in ???.
MODIFICATION HISTORY:
JUN-2004, Paul Hick (UCSD/CASS)
JUL-2008, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
Both mean and median are now calculated and returned in
dark_aux(SMEI__DRK_MEAN) and dark_aux(SMEI__DRK_MEDIAN).
The return value dark_val is one of these two, depending
on setting of bMedian.
[Previous]
[Next]
NAME:
smei_frm_fts
PURPOSE:
Write SMEI CCD frame to Fits file
CALLING SEQUENCE:
subroutine smei_frm_fts(cFile,nx,ny,nb,frame,hdr,bforce)
INPUTS:
cFile*(*) character fully-qualified Fits filename
nx integer 1st array dimension
ny integer 2nd array dimension
nb integer 2=int 2; 4=int 4; -4=float
frame(*) real CCD frame array
hdr(*) double precision CCD header array
bforce logical if .TRUE. then force overwrite
if file exists already.
CALLS: ***
FTCLOS, FTINIT, FTPHPR, FTPKND, FTPKYD, FTPKYJ, FTPKYS, FTPPRE, FTPPRI, FTPPRJ, Time2Str
iFreeLun, iGetFileSpec, iGetLun, iOSDeleteFile, iSetFileSpec, say_fts
smei_frm_fts_axis, smei_frm_fts_base, smei_frm_fts_eph, smei_hdr_str
smei_hdr_time
CALLED BY:
smei_base, smei_cal_build, smei_frm_write
INCLUDE:
include 'filparts.h'
include 'smei_frm_hdr.h'
include 'smei_frm_layout.h'
MODIFICATION HISTORY:
JUN-2008, Paul Hick)
Added documentation.
APR-2009, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
Added bforce argument.
[Previous]
[Next]
NAME:
smei_frm_fts_axis
PURPOSE:
Process header entries for optical axis
CALLING SEQUENCE:
subroutine smei_frm_fts_axis(iU, hdr)
INPUTS:
iU integer logical unit number of open Fits file
hdr(*) double precision SMEI header array
OUTPUTS:
CALLED BY:
smei_frm_fts, smei_frm_write
INCLUDE:
include 'smei_frm_hdr.h'
CALLS: ***
FTUKYD, dasind, datan2d, quaternion_rotate_xyz, say_fts, smei_hdr_quaternion
PROCEDURE:
Header entries for RA, dec and PA of optical axis are written
into the open Fits file.
MODIFICATION HISTORY:
MAR-2005, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
[Previous]
[Next]
NAME:
smei_frm_fts_base
PURPOSE:
Process header entries for optical axis
CALLING SEQUENCE:
subroutine smei_frm_fts_base(iU, hdr)
INPUTS:
iU integer logical unit number of open Fits file
hdr(*) double precision SMEI header array
OUTPUTS:
CALLED BY:
smei_frm_fts, smei_frm_write
INCLUDE:
include 'filparts.h'
include 'smei_frm_hdr.h'
CALLS: ***
FTUKYD, FTUKYG, FTUKYJ, FTUKYS, iGetFileSpec, iSetFileSpec, say_fts, smei_hdr_flag
smei_hdr_str
PROCEDURE:
Header entries related to the base calculation are written into
the open Fits file. In addition all binary flags are combined into
the header entry SMEI__HDR_FLAGS and is written into the file.
The Fits update functions FTUK* are used because this routine is
used both to create the original Fits file and to update them.
MODIFICATION HISTORY:
MAR-2005, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
[Previous]
[Next]
NAME:
smei_frm_fts_eph
PURPOSE:
Process ephemeris related entries in SMEI header
CALLING SEQUENCE:
subroutine smei_frm_fts_eph(iU,hdr)
INPUTS:
iU integer logical unit number of open Fits file
hdr(*) double precision SMEI header array
OUTPUTS:
hdr(SMEI__HDR_ECLIPSE)
hdr(SMEI__HDR_SHADOW)
filled by calls to smei_eclipse
(but still need to be written to Fits file by
a subsequent call to smei_frm_fts_base
(where they are incorporated into the
SMEI__HDR_FLAGS entry).
CALLED BY:
smei_frm_fts, smei_frm_write
INCLUDE:
include 'smei_frm_hdr.h'
CALLS: ***
FTUKYD, Say, say_fts, smei_eclipse, smei_hdr_eph, smei_hdr_time
PROCEDURE:
Unit vectors for Sun, Moon, and Venus in the UCSD camera frame
are calculated and written into the open Fits file.
The Fits update functions FTUK* are used because this routine is
used both to create the original Fits file and to update them.
(there do not seem to be update routines for arrays of
parameter values, so we use the update function TPUK* for
each individual element).
MODIFICATION HISTORY:
MAR-2005, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
[Previous]
[Next]
NAME:
smei_frm_get
PURPOSE:
Finds SMEI frame in specified time period
CALLING SEQUENCE:
logical function smei_frm_get(iFirst,TBeg,TEnd,icam,mode,bdig,cBase,cFrmSpec)
INPUTS:
iFirst integer 1 for new search
0 to continue search
TBeg(2) integer start time
TEnd(2) integer end time
icam integer camera number (1,2,3)
passed to smei_frm_path
mode integer mode number (0,1,2)
bdig integer
cBase*(*) character root directory of SMEI DB
passed to smei_frm_path
OUTPUTS:
cFrmSpec*(*) character fully qualified name of SMEI frame.
CALLED BY:
smei_cal, smei_frm_getlist, smei_orb
INCLUDE:
include 'filparts.h'
CALLS: ***
Time2Differ, smei_Time2Split, smei_frm_getfirst, smei_frm_getnext, smei_frm_path
PROCEDURE:
Typically this function is used in a construct like this:
include 'openfile.h'
include 'smei_frm_layout.h'
cBase = ' '
call smei_Time2 Split(1, cFrameBeg, TBeg)
call smei_Time2 Split(1, cFrameEnd, TEnd)
icam = 1
iFirst = 1
do while (smei_frm_get(iFirst, TBeg, TEnd, icam, cBase, cFrmSpec))
if (bReadNic(OPN__REOPEN+OPN__STOP, cFrmSpec, SMEI__FRM_NPIX, nx, ny, nb, frame, ctrailer)) then
(process frame data in array frame)
end if
end do
As long as smei_frm_get returns .TRUE. cFrmSpec should return
frame names from TBeg to TEnd in chronological order.
MODIFICATION HISTORY:
JUN-2004, Paul Hick (UCSD/CASS)
FEB-2005, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
Added check to make sure that the first record found
wit t > TBeg also has t <= TEnd.
[Previous]
[Next]
NAME:
smei_frm_getfirst
PURPOSE:
(internal use by smei_frm_get)
CALLING SEQUENCE:
logical function smei_frm_getfirst(iFind,cPath,TTime,mode,cFrmSpec)
INPUTS:
iFind integer 1 for new search
0 to continue search
(passed to iSearch)
cPath*(*) character directory is SMEI data base where
data for current doy are located.
TTime(2) integer test time
mode integer mode number (0,1,2)
OUTPUTS:
smei_frm_getfirst
logical .TRUE. if a frame is found with the mode
less than requested or if the mode is OK
but T < TTime
.FALSE. if no frame is found, or if a frame
is found with a mode larger than requested
(cFrmSpec is set to blank string).
.FALSE. if a frame is found with the right mode
and T >= TTime. cFrmSpec contains the
fully-qualified file name
cFrmSpec*(*) character Fully qualified file name of SMEI frame
or blank string
CALLED BY:
smei_frm_get
INCLUDE:
include 'filparts.h'
CALLS: ***
Time2Differ, bOSFindClose, iFilePath, iGetFileSpec, iSearch, iSetFileSpec
smei_Time2Split
PROCEDURE:
smei_frm_get calls this routine in a while loop that terminates if
.FALSE. is returned. On a .FALSE. return, cFrmSpec contains a filename
only if it has the right mode, and T >= TTime.
MODIFICATION HISTORY:
MAR-2005, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
[Previous]
[Next]
NAME:
smei_frm_getlist
CALLING SEQUENCE:
integer function smei_frm_getlist(TBeg,TEnd,icam,mode,bdig,cBase,cList)
CALLED BY:
smei_base, smei_skyd
INCLUDE:
include 'openfile.h'
include 'dirspec.h'
include 'filparts.h'
include 'smei_frm_layout.h'
CALLS: ***
GETPID, Int2Str, Str2Str, Time2Str, bOpenFile, iFilePath, iFreeLun, iGetFileSpec
iSetFileSpec, itrim, smei_frm_get
MODIFICATION HISTORY:
JUN-2004, Paul Hick (UCSD/CASS)
MAR-2005, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
Mode argument was there already, but was not doing anything.
Now it does.
[Previous]
[Next]
NAME:
smei_frm_getnext
PURPOSE:
(internal use by smei_frm_get)
CALLING SEQUENCE:
logical function smei_frm_getnext(iFind,cPath,TTime,mode,cFrmSpec)
INPUTS:
iFind integer 1 for new search
0 to continue search
(passed to iSearch)
cPath*(*) character directory is SMEI data base where
data for current doy are located.
TTime(2) integer test time
mode integer mode number (0,1,2)
OUTPUTS:
smei_frm_getnext
logical .TRUE. if a frame is found with mode less than
requested.
.FALSE. if no frame is found, cFrmSpec is blank
.FALSE. if frame is found with mode larger than
requested. cFrmSpec is blank
.FALSE. if frame is found right mode but with
T > TTime; cFrmSpec is blank
.FALSE. if frame is found with right mode and
T <= TTime; cFrmSpec contains
fully-qualified filename
cFrmSpec*(*) character Fully qualified file name of SMEI frame
or blank string
CALLED BY:
smei_frm_get
INCLUDE:
include 'filparts.h'
CALLS: ***
Time2Differ, bOSFindClose, iFilePath, iGetFileSpec, iSearch, iSetFileSpec
smei_Time2Split
PROCEDURE:
smei_frm_get calls this routine in a while loop, that terminates
when .FALSE. is returned. On a .FALSE. return cFrmSpec contains a
filename only if it has the right mode and T <= TTime.
MODIFICATION HISTORY:
MAR-2005, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
[Previous]
[Next]
NAME:
smei_frm_hdr
PURPOSE:
Parameter definition for handling Fits frame headers
CALLING SEQUENCE:
include 'smei_frm_hdr.h'
INCLUDED BY:
NicHdr, Peep, smei_base, smei_cal, smei_cal_bin, smei_cal_build, smei_frm_clean
smei_frm_fts, smei_frm_fts_axis, smei_frm_fts_base, smei_frm_fts_eph
smei_frm_ok, smei_frm_read, smei_frm_saturated, smei_frm_write, smei_hdr_flag
smei_hdr_quaternion, smei_hdr_str, smei_hdr_time, smei_orb, smei_skyd
smei_skyd_sky
PROCEDURE:
Used as array indices into the real*8 array used to
store the Fits header.
MODIFICATION HISTORY:
FEB-2005, Paul Hick (UCSD/CASS)
JUL-2008, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
Added SMEI__DARK_MEAN
[Previous]
[Next]
NAME:
smei_frm_hdrok
PURPOSE:
Parameters for Fits header entries set in smei_frm_ok
CATEGORY:
gen/for/h
CALLING SEQUENCE:
include 'smei_frm_hdrok'
INCLUDED BY:
smei_frm_ok, smei_orb, smei_skyd, smei_skyd_sky
MODIFICATION HISTORY:
JUN-2006, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
[Previous]
[Next]
NAME:
smei_frm_layout
PURPOSE:
Include file with parameter definitions for SMEI data frames
CATEGORY:
ucsd/camera/for/h
CALLING SEQUENCE:
include 'smei_frm_layout.h'
INCLUDED BY:
NicHdr, Peep, smei_base, smei_cal, smei_cal_add, smei_cal_bin, smei_cal_build
smei_cal_c3mask, smei_cal_get, smei_cal_read, smei_cal_write, smei_frm_base
smei_frm_c3fudge, smei_frm_c3mask_active, smei_frm_clean, smei_frm_dark
smei_frm_fts, smei_frm_getlist, smei_frm_measle, smei_frm_mode, smei_frm_path
smei_frm_ped, smei_frm_pickup, smei_frm_read, smei_frm_saturated, smei_frm_stats
smei_frm_write, smei_get_glare, smei_get_lsff, smei_orb, smei_orb_get
smei_orb_min, smei_orb_mkname, smei_orb_read, smei_orb_write, smei_sky_iread
smei_sky_read, smei_skyd, smei_skyd_sky
PROCEDURE:
Frame layout for mode 0 (engineering mode)
MODIFICATION HISTORY:
JUN-2004, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
[Previous]
[Next]
NAME:
smei_frm_measle
PURPOSE:
Measle detector
CATEGORY:
CALLING SEQUENCE:
subroutine smei_frm_measle(kill,icam,nx,ny,frame,count,count_big,mask,indx)
INPUTS:
kill logical .TRUE. : set measles to bad value
.FALSE.: set measles to neighbours average
icam integer camera number (1,2,3)
not used yet
nx integer horizontal frame size (1272 for mode 0)
ny integer vertical frame size (256 for mode 0)
frame(nx,ny) real SMEI frame after pedestal and dark current have been subtracted
indx(nx,ny) integer scratch array
OUTPUTS:
frame(nx,ny) real SMEI frame with value of measles replace by a
an neighbours average.
Only the uncovered pixels are tested. Pedestal and dark current
areas are not modified.
mask(nx,ny) integer 1 if pixel is OK
0 if pixel is flagged as measle
mask will be 1 for all pedestal and dark current pixels.
count integer # measles found
count_big integer # big measles (with at most 3 of the neighbour pixels
modified too
CALLED BY:
smei_base, smei_cal
INCLUDE:
include 'smei_frm_layout.h'
CALLS: ***
ArrI4Constant, ArrR4GetMinMax, BadR4, IndexR4, iArrR4ValuePresent, smei_FitPlane
smei_frm_mode
PROCEDURE:
Uses the ADUs departure of
a pixel from its neighbors-average z0 to trigger its replacement/elimination.
The response must be above a fixed value "val_cut" and be at least double the
8-pixel average response z0. Also, the departure from the neighbors average
is compared to the difference of neighboring pixels on opposing sides of the
center pixel.
MODIFICATION HISTORY:
JUN-2004, Andy Buffington (UCSD/CASS; abuffington@ucsd.edu), Paul Hick (UCSD/CASS; pphick@ucsd.edu)
[Previous]
[Next]
NAME:
smei_frm_mode
PURPOSE:
Get mode and binning factor for SMEI data
CATEGORY:
ucsd/camera/for/lib
CALLING SEQUENCE:
integer function smei_frm_mode(N, ibin)
INPUTS:
N integer identifies size of SMEI frame
Can be horizontal size, vertical size
or total number of pixels in frame
OUTPUTS:
smei_frm_mode integer mode ID (0, 1 or 2)
ibin integer binning factor (=2^mode, i.e. 1,2 or 4)
CALLED BY:
smei_cal, smei_cal_build, smei_frm_base, smei_frm_clean, smei_frm_measle
smei_frm_pickup, smei_frm_stats, smei_orb, smei_orb_min
INCLUDE:
include 'smei_frm_layout.h'
MODIFICATION HISTORY:
JUN-2004, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
[Previous]
[Next]
NAME:
smei_frm_ok
PURPOSE:
Process command line arguments related to frame selection
CALLING SEQUENCE:
logical function smei_frm_ok(cArg,cName,hdr,hdrok,iSilent)
INPUTS:
cName*(*) character file name of frame
cArg*(*) character command line keywords
hdr(*) double precision frame header array
iSilent integer higher value suppresses more
informational messages
CALLED BY:
smei_orb, smei_skyd
INCLUDE:
include 'smei_frm_hdr.h'
include 'smei_frm_hdrok.h'
CALLS: ***
ArrR8Copy, ArrR8Zero, Dbl2Str, ForeignArgSet, ForeignI4Arg, ForeignR8ArgN, Int2Str
Say, Str2Str, datan2d, itrim
PROCEDURE:
bodyexcl(4,3) double precision
defines exclusion area around optical axis for Sun, Moon
and Venus: if Sun, Moon or Venus are inside the exclusion
area the frame will not be used for indexing.
The exclusion area is defined in terms of
theta-x = atan(rx,rz) and theta-y=atan(ry/rz), where
(rx,ry,rz) is the unit vector to Sun, Moon, Venus in the
camera coordinate frame
If
bodyexcl(1,i) <= theta_x <= bodyexcl(2,i)
bodyexcl(3,i) <= theta_y <= bodyexcl(4,i)
then the corresponding frame is excluded, where
i=0 is the Sun, i=1 is the Moon, i=2 is Venus.
The values for the Sun are extracted from cmd line arg
-sunbox=tx1,tx2,ty1,ty2. The moon is extracted
from -moonbox=tx1,tx2,ty1,ty2, and Venus from
-venusbox=tx1,tx2,ty1,ty2 (all angles in degrees).
Setting keyword -avoid_moon is equivalent to
-moonbox=-42,42,-6.5,6.5 degrees.
MODIFICATION HISTORY:
MAY-2005, Paul Hick (UCSD/CASS)
JUL-2006, Paul Hick (UCSD/CASS)
Added check for bad quaternions.
NOV-2008, Paul Hick (UCSD/CASS)
Added default box for avoiding Sun.
Fixed bug in processing of avoid* keywords.
[Previous]
[Next]
NAME:
smei_frm_path
PURPOSE:
Determines directory where frame for given time and camera
is located
CATEGORY:
CALLING SEQUENCE:
integer function smei_frm_path(bdig, cFile, TT, camera, cBase, cPath)
INPUTS:
bdig logical =.FALSE.: return base drive (e.g. /smeidb/db3/
=.TRUE. : return base directory (e.g. /smeidb/db3/2004_001/)
cFile character*(*) file name of SMEI frame (without directory)
if itrim(cFile) .ne. 0 then TT and camera are
extracted from the frame name
TT(2) integer standard 2-element time
camera integer camera number
cBase*(*) character root directory of SMEI DB
if left blank than the environment variables
SMEIDB1, SMEIDB2, etc. are used
OUTPUTS:
TT(2) integer if cFile .ne. ' ', frame time
camera integer if cFile .ne. ' ', camera number
cPath*(*) character directory where frame is located
CALLS: ***
Say, Str2Flt, Str2Flt_Format, Time2Differ, Time2Str, Time2YDoy, bOpenFile, cInt2Str
iFilePath, iFreeLun, iGetLogical [1], iGetLogical [2], itrim, smei_Time2Split
CALLED BY:
smei_cal, smei_frm_get, smei_frm_read, smei_frm_read_get_sdark, smei_frm_write
INCLUDE:
include 'dirspec.h'
include 'openfile.h'
include 'filparts.h'
include 'smei_frm_layout.h'
RESTRICTIONS:
Env variables $SMEIDB1, $SMEIDB2, etc. need to be stored in the
log file $HOME/LOGFIL.TXT (this should be done automatically by the login
script $com/login.
PROCEDURE:
If cFile is not a blank string, it should be the filename (without directory)
of a SMEI frame, e.g. c1frm_2003_123456. The file type is ignored.
If cFile is the blank string then arguments TT and camera are used to construct
a frame name.
MODIFICATION HISTORY:
JUN-2004, Paul Hick (UCSD/CASS)
NOV-2007, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
Maximum number of drives is now 16 (was 8)
[Previous]
[Next]
NAME:
smei_frm_ped
PURPOSE:
Calculate pedestal for SMEI data frame
CATEGORY:
CALLING SEQUENCE:
integer function smei_frm_ped(cframe,nx,ny,frame,pattern,ped_val,ped_aux)
INPUTS:
cframe character*(*) frame name (contains time and camera)
nx integer horizontal frame size
ny integer vertical frame size
frame(nx,ny) real frame data (after massaging by smei_frm_clean)
pattern(nx,ny) real "shutter-closed" calibration pattern
The pattern is only used if ped_aux(SMEI__PED_RIGHT_OFFSET)
is NOT bad, in which case it is subtracted from the
pedestal columns prior to updating the left-right offset
stored in this element of ped_aux.
This is only used for camera 3 when both sides of the frame
are used for the pedestal determination.
ped_aux(*) real six entries:
ped_aux(SMEI__PED_RIGHT_OFFSET)
Offset between mean left and right pedestal. If not
set to bad than naive means are calculated after taking
out the pattern and this left-to-right offset.
If set to bad, then the pattern array is not accessed.
ped_aux(SMEI__PED_MEAN_REF ) mean 'reference' pedestal
ped_aux(SMEI__PED_MEAN_EXCESS ) mean excess
frames with naive mean above the threshold
ped_aux(SMEI__PED_MEAN_REF)+ped_aux(SMEI__PED_MEAN_EXCESS)
are rejected.
If the right-to-left offset ped_aux(SMEI__PED_RIGHT_OFFSET)
is not bad then the means are calculated after taking out
the pattern and the right-to-left offset.
ped_aux(SMEI__PED_MEDIAN_DEFICIT)
ped_aux(SMEI__PED_MEDIAN_EXCESS )
only pedestal pixels with values between
the naive median pedestal+median_deficit and
naive median pedestal+median_excess.
are used to get the final pedestal.
If set to BadR4() the corresponding
restriction is not applied
OUTPUTS:
smei_frm_ped integer # pixels used in final pedestal calculation
If only the left side of the frame is
used for the pedestal calculation, i.e. if
ped_aux(SMEI__PED_LEFT_SIDE_ONLY) .ne. bad,
then the result is multiplied by 2 before
returning.
ped_val real pedestal
value will be bad if
- no valid pedestal pixels (smei_frm_ped=0)
- mean pedestal higher than ped_mean_ref+ped_mean_excess
ped_aux(*) real six entries:
ped_aux(SMEI__PED_RIGHT_OFFSET ) updated right-to-left offset
Updated only if input was not bad. Update depends on input
value of ped_aux(SMEI__PED_MEAN_EXCESS).
ped_aux(SMEI__PED_LEFT_SIDE_ONLY) use left ped cols only
used only if ped_aux(SMEI__PED_RIGHT_OFFSET) is set to bad
(no pattern used).
ped_aux(SMEI__PED_NAIVE_MEAN ) naive mean pedestal
ped_aux(SMEI__PED_NAIVE_MEDIAN ) naive pedestal median
ped_aux(SMEI__PED_MEDIAN_LOW ) naive median+median_deficit
ped_aux(SMEI__PED_MEDIAN_HIGH ) naive median+median_excess
ped_aux(SMEI__PED_VERY_LOW ) ??
ped_aux(SMEI__PED_STDEV ) standard dev. of ped_val
CALLS: ***
ArrR4AddConstant, ArrR4Mean, ArrR4Median, ArrR4MinusArrR4, ArrR4Stdev, BadR4, Say
cFlt2Str, smei_frm_ped_guess, smei_frm_pickup
CALLED BY:
smei_cal_build, smei_frm_base
SEE ALSO:
smei_frm_clean
RESTRICTIONS:
The median deficit must be negative, the median excess must
be positive. If not, all bets are off.
INCLUDE:
include 'smei_frm_layout.h'
include 'smei_frm_basepar.h'
PROCEDURE:
SMEI__* parameters are defined in the two include files.
Better check the code to find out what 'naive' means
these days.
Only the pedestal values in the frame are accessed (4
columns left and right in engineering mode)
First the 'naive' mean pedestal (average over all pedestal
pixels with valid values) is calculated and compared with
ped_mean_ref+ped_mean_excess. If the 'naive' mean is higher
than ped_mean_ref+ped_mean_excess the pedestal is rejected.
If this first test is passed then the median pedestal is
calculated. All pedestal pixels more than ped_median_excess
above the median are rejected. (the median+ped_median_excess
is returned in ped_median_high).
The mean of the remaining pixels is returned as the
pedestal ped_val
MODIFICATION HISTORY:
JUN-2004, Paul Hick (UCSD/CASS)
FEB-2007, Paul Hick (UCSD/CASS)
Added option to use only left side of frame to calculate
the pedestal when the pattern is not used.
NOV-2008, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
Added argument cframe.
Mean pedestal is now calculated with smei_frm_ped_guess.
A constant value (hardcoded in smei_base and smei_cal)
was passed in as ped_aux(SMEI__PED_MEAN_REF).
This is not accessed anymore.
[Previous]
[Next]
NAME:
smei_frm_ped_guess
PURPOSE:
Used to get a "best guess" for the pedestal of a CCD frame.
Set mean reference pedestal
CALLING SEQUENCE:
function smei_frm_ped_guess(cframe)
INPUTS:
cframe character*(*) frame name
(contains time and camer number)
CALLED BY:
smei_frm_base, smei_frm_ped
INCLUDE:
include 'filparts.h'
CALLS: ***
Say, Time2DHMS, Time2Day, Time2Delta, Time2YMD, cFlt2Str, iGetFileSpec, iSetFileSpec
smei_Time2Split
RESTRICTIONS:
PROCEDURE:
Currently the mean pedestal is calculated from a linear
trend with time based on 5 years of data.
MODIFICATION HISTORY:
NOV-2008, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
AUG-2010, John Clover (UCSD/CASS)
Changed camera 2 pedestal change per day to 0.01252
[Previous]
[Next]
NAME:
smei_frm_pickup
PURPOSE:
Pick up pedestal or dark current pixels
CATEGORY:
ucsd/camera/for/lib
CALLING SEQUENCE:
integer function smei_frm_pickup( id, nx, ny, frame, pixs )
INPUTS:
id integer mod(id,4)=0: pick up pedestal pixels
mod(id,4)=1: pick up dark current pixels
mod(id,4)=2: pick up squares outside FOV arc
mod(id,4)=3: pick up center inside FOV arc
bit 2 NOT set: do not pick up left side of CCD
bit 2 SET : pick up left side of CCD
bit 3 NOT set: do not pick up right side of CCD
bit 3 SET : pick up right side of CCD
If neither bit 2 nor bit 3 are set then both
left and right side are extracted (i.e. both
bits are assumed SET).
nx integer horizontal frame size
ny integer vertical frame size
frame (nx,ny) real frame data
OUTPUT:
smei_frm_pickup integer # pedestal or dark current pixels
pixs(n) real frame values in pedestal or dark current pixels
CALLED BY:
smei_base, smei_cal, smei_frm_dark, smei_frm_ped
INCLUDE:
include 'smei_frm_layout.h'
CALLS: ***
smei_frm_mode
MODIFICATION HISTORY:
DEC-2004, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
[Previous]
[Next]
NAME:
smei_frm_ratio
PURPOSE:
Set dark current ratio for camera 3, mode 1
CALLING SEQUENCE:
function smei_frm_ratio(tt)
INPUTS:
tt integer(2) SMEI frame time
CALLS: ***
Say, Time2DHMS, Time2Day, Time2Delta, Time2YMD, cFlt2Str, cTime2Str
CALLED BY:
smei_frm_base
PROCEDURE:
The dark ratio is from a fit to a function
f(t) = 1-exp(-(t-b)/a)
where t is the number of days since 2003/04/15 0 UT
The fit is done by the IDL procedure smei_frm_darkratio.pro
RESTRICTIONS:
The origin t0 (currently 2003/04/15 0 UT) MUST match the
origin in the IDL procedure!!.
MODIFICATION HISTORY:
NOV-2005, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
[Previous]
[Next]
NAME:
smei_frm_read
PURPOSE:
Read SMEI frame
CATEGORY:
I/O
CALLING SEQUENCE:
logical function smei_frm_read(iAct0,cFile,N,nX,nY,nB,Img,hdr,headroom)
INPUTS:
iAct0 integer open code passed to bOpenFile
Usually set to zero. If cFile is known
to exist (e.g. a return value from
iSearch) then file access can be
made more efficient by using the value
OPN__REOPEN (defined in openfile.h).
cFile character*(*) file name. If no explicit directory
is specified then the SMEI databases
are tried, first SMEIDC, then SMEIDB.
N integer size of Img
OUTPUTS:
smei_frm_read logical .TRUE. : success
.FALSE.: failure
nX integer horizontal size of image
nY integer vertical size of image
nB integer # bytes per number on input file
2 for integer*2
4 for integer*4
-4 for real*4
Img(nX*nY) real image data
(the image read from file divided by the
the headroom)
hdr(*) double precision
array with frame header entries
headroom real headroom (1.0 or 0.75)
CALLS: ***
ArrR4TimesConstant, ArrR8Zero, FTCLOS, FTGISZ, FTGKND, FTGKYD, FTGKYJ, FTGKYS, FTGPVE
FTNOPN, NicHdr, Say, Time2Str, bReadNic, iFreeLun, iGetFileSpec, iGetLun, iSetFileSpec
say_fts, smei_Time2Split, smei_frm_c3mask_active, smei_frm_path, smei_hdr_flag
smei_hdr_str, smei_hdr_time
CALLED BY:
Peep, smei_base, smei_cal, smei_cal_build, smei_orb, smei_skyd
SEE ALSO:
bWriteFrm, bWriteNic
RESTRICTIONS:
Reading of *.gz files depends on availability of gzip
(windows) or gunzip (Linux).
INCLUDE:
include 'filparts.h'
include 'smei_frm_layout.h'
include 'smei_frm_hdr.h'
include 'ftspar.h'
PROCEDURE:
See bReadNic
MODIFICATION HISTORY:
JUN-2004, Paul Hick (UCSD/CASS)
JUN-2005, Paul Hick (UCSD/CASS)
Added check for presence of VERSION keyword in header. In
early Fits files produced by IDL this keyword was not present.
AUG-2005, Paul Hick (UCSD/CASS)
Fixed bug that affected the factor two compensation applied to
correct for the onboard gain change in Feb 2005 for cam 2, mode 1.
The frame time was not picked up correctly from the header.
APR-2006, Paul Hick (UCSD/CASS)
If no directory is specifed in cFile, first SMEIDC, then SMEIDB
is tried (only SMEIDB was checked before).
JUN-2007, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
Bug fixes. For time periods with a "bad pixel" mask onboard
(smei_frm_c3mask_active(0,ctime,-1,cmask)=1)
two errors were made:
- For camera 3, mode 1, the gain change of a factor two was
not applied to frames with the flat_enabled flag off (zero)
In smei_base this would have failed all frames.
In smei_cal this would have had no effect (the mask setting
is not used when mode=0 and flat_enabled=0 as is the case
for the weekly calibration data).
In smei_orb the orbital pattern would have been wrong when
flat_enabled=0. This occurs the first time after 2007_133,
but this has not yet been run through smei_orb at this time.
In smei_skyd the skyamp would have been wrong also if
flat_enabled=0, i.e after 2007_133, but these data have not
been run yet.
- For cameras 1 and 2 the headroom 0.75 was not corrected for
if flat_enabled=1.
In smei_base this would have resulted in a pedestal and
and dark current of 0.75 the correct value.
In smei_base this would have had no effect (since always
flat_enabled=0 for the weekly calibration data)
smei_orb is never run for cameras 1 and 2.
In smei_skyd the resulting skymap would be too low by
about 0.75 if the same error was made in smei_base. However,
if the pedestal and dark current were calculate with
a smei_base version < 4.00, then the error would not be
a simple scaling.
[Previous]
[Next]
NAME:
smei_frm_read_get_sdark
CALLING SEQUENCE:
entry smei_frm_read_get_sdark(idark)
CALLS: ***
ArrR4TimesConstant, ArrR8Zero, FTCLOS, FTGISZ, FTGKND, FTGKYD, FTGKYJ, FTGKYS, FTGPVE
FTNOPN, NicHdr, Say, Time2Str, bReadNic, iFreeLun, iGetFileSpec, iGetLun, iSetFileSpec
say_fts, smei_Time2Split, smei_frm_c3mask_active, smei_frm_path, smei_hdr_flag
smei_hdr_str, smei_hdr_time
CALLED BY:
smei_orb_get
[Previous]
[Next]
NAME:
smei_frm_read_set_dark
CALLING SEQUENCE:
entry smei_frm_read_set_sdark(idark)
[Previous]
[Next]
NAME:
smei_frm_saturated
PURPOSE:
Count saturated pixels
CATEGORY:
ucsd/camera/for/lib
CALLING SEQUENCE:
integer function smei_frm_saturated(hdr, frame)
INPUTS:
hdr(*) double precision SMEI frm header
frame(*) real frame data (from smei_frm_read)
OUTPUTS:
smei_frm_saturated
integer # saturated pixels
CALLS:
iArrR4ValuePresent
CALLED BY:
smei_base, smei_cal
INCLUDE:
include 'smei_frm_layout.h'
include 'smei_frm_hdr.h'
PROCEDURE:
If the onboard flatfield is NOT enable then every pixel
with readout >= 65533 is counted as saturated.
(strictly speaking the saturation value is 65535, but for
camera 3 in mode 1 the highest value appears to be
65533 at least some of the time).
If the onboard flatfield is enabled (and the headroom of
0.75 is applied) then 49147 is used).
MODIFICATION HISTORY:
JUN-2004, Paul Hick (UCSD/CASS)
AUG-2005, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
Changed saturation value from 65535 to 65533.
[Previous]
[Next]
NAME:
smei_frm_stats
PURPOSE:
Determines some stats on frame after measle removal
CALLING SEQUENCE:
subroutine smei_frm_stats(nx,ny,frame,pixsum,ipixsum,pixdif,ipixdif)
INPUTS:
nx integer
ny integer
frame(nx,ny) real
OUTPUTS:
pixsum real
ipixsum integer
pixdif real
ipixdif integer
CALLED BY:
smei_base, smei_cal
INCLUDE:
include 'smei_frm_layout.h'
CALLS: ***
BadR4, smei_frm_mode
MODIFICATION HISTORY:
[Previous]
[Next]
NAME:
smei_frm_write
PURPOSE:
Write or update SMEI frame as Fits file.
CATEGORY:
gen/for/lib
CALLING SEQUENCE:
subroutine smei_frm_write(cFrm, hdr, cDest, bdig, bnodups)
INPUTS:
cFrm
hdr
cDest
bdig
bnodups
CALLED BY:
smei_base
INCLUDE:
include 'filparts.h'
include 'openfile.h'
include 'smei_frm_hdr.h'
include 'smei_frm_layout.h'
include 'ftspar.h'
CALLS: ***
FTCLOS, FTGISZ, FTGPVE, FTNOPN, Say, Str2Str, iCheckDirectory, iFreeLun, iGetFileSpec
iGetLun, iOSDeleteFile, iOSSpawnCmd, iSetFileSpec, itrim, say_fts, smei_frm_fts
smei_frm_fts_axis, smei_frm_fts_base, smei_frm_fts_eph, smei_frm_path
PROCEDURE:
MODIFICATION HISTORY:
FEB-2005, Paul Hick (UCSD/CASS)
JUL-2008, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
Introduced smei_frm_fts call to write new Fits file
[Previous]
[Next]
NAME:
smei_get_glare
PURPOSE:
Get glare map
CALLING SEQUENCE:
subroutine smei_get_glare(icam, mode, glare_map, glare_factor, cx, cy, dx, dy)
INPUTS:
OUTPUTS:
icam integer camera (1,2,3)
mode integer mode (0,1,2)
glare_map real 318x64 (mode 2) frame representing the glare
glare_factor real 90x180 array of multipliers for the glare map
cx real
cy real
dx real
dy real
CALLED BY:
smei_skyd_fts, smei_skyd_init, smei_skyd_make, smei_skyd_sky
INCLUDE:
include 'filparts.h'
include 'dirspec.h'
include 'smei_frm_layout.h'
include 'ftspar.h'
CALLS: ***
FTCLOS, FTGISZ, FTGKYE, FTGPVE, FTNOPN, Int2Str, Say, Str2Str, iFilePath, iFreeLun, iGetLun
say_fts
RESTRICTIONS:
glare_map MUST be a 318 x 64 array
glare_factor MUST be a 90 x 180 array
PROCEDURE:
The glare map represents the shape of the glare as present in
the SMEI frames as a mode 2 (318x64) array.
This glare map, multiplied by a constant, is subtracted from
each SMEI frame. The multiplier is a function of the location
of the Sun relative to the optical axis.
The glare_factor array represents this multiplier as a function
of two angles thetax and thetay.
MODIFICATION HISTORY:
DEC-2004, Paul Hick (UCSD/CASS)
DEC-2007, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
Now using WCS-compliant keywords.
[Previous]
[Next]
NAME:
smei_get_lsff
PURPOSE:
Get flat field correction.
CALLING SEQUENCE:
subroutine smei_get_lsff(mode,icam,flatfield)
INPUTS:
icam integer camera number (1,2,3)
mode integer camera mode (0,1,2)
OUTPUTS:
flatfield(*) real flatfield correction
CALLED BY:
smei_skyd_fts, smei_skyd_init, smei_skyd_make, smei_skyd_sky
INCLUDE:
include 'filparts.h'
include 'dirspec.h'
include 'smei_frm_layout.h'
include 'ftspar.h'
CALLS: ***
BADR4SET, FTCLOS, FTGISZ, FTGPVE, FTNOPN, GridFill, iFilePath, iFreeLun, iGetLun, say_fts
PROCEDURE:
The first nX * nY elements of flatfield will be filled where
nX = 1272, 636 or 318 and nY = 256, 128, 64 for mode 0,1 and
2, respectively.
MODIFICATION HISTORY:
DEC-2004, Paul Hick (UCSD/CASS)
JAN-2006, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
Replaced all zeroes by one in output array.
[Previous]
[Next]
NAME:
smei_get_starmask
PURPOSE:
Read in star masks for indexing.
CALLING SEQUENCE
subroutine smei_get_starmask(bNoStarMask,n_eq, n_pl, mask)
INPUTS:
bNoStarMask logical .FALSE.: use star mask (read from
file $SMEIDB/starmask.fts.gz)
.TRUE : set mask to zero everywhere
n_eq integer number of bins in hires equatorial map
n_pl integer number of bins in hires polar maps
OUTPUTS:
mask(n_eq+2*n_pl)
integer mask values:
0: indicates skybin away from bright star
1: indicates skybin close to bright star.
CALLED BY:
smei_skyd_fts, smei_skyd_init, smei_skyd_make, smei_skyd_sky
INCLUDE:
include 'filparts.h'
include 'dirspec.h'
include 'ftspar.h'
CALLS: ***
ArrI4Zero, FTCLOS, FTGISZ, FTGPVJ, FTMAHD, FTNOPN, Say, iFilePath, iFreeLun, iGetLun
say_fts
[Previous]
[Next]
NAME:
smei_hdr_eph
PURPOSE:
Get direction to specified body in camera coordinate frame
CALLING SEQUENCE:
logical function smei_hdr_eph(hdr,id,nbody,rx,ry,rz)
INPUTS:
hdr(*) double precision
SMEI frame header
id integer 0: geocentric direction, using JPL ephemeris
1: geocentric direction, use USNO ephemeris (not implemented yet)
2: topocentric direction, using JPL ephemeris
3: topocentric direction, use USNO ephemeris (not implemented yet)
The topocentric direction takes the spacecraft location
into account.
nbody integer 0,..,10
Any of the bodies used by the JPL ephemeris
OUTPUTS:
rx,ry,rz double precision
x,y,z components of a unit vector
in the UCSD camera coordinate frame.
CALLS: ***
Time2jpl_eph, Time2smei_eph, quaternion_rotate_xyz, smei_hdr_quaternion
smei_hdr_time
CALLED BY:
smei_frm_fts_eph
RESTRICTIONS:
It may be necessary to close the JPL ephemeris
with a call to jpl_close()
PROCEDURE:
(rx,ry,rz) is a vector on the unit sphere defining the
direction to the selected body. The components are defined
in the UCSD camera coordinate frame.
Several angles can be derived from this.
The direction cosine angles follow by taking the arcsin:
tx = asind(rx)
ty = asind(ry)
The rotation angles (needed for the glare removal):
tx = asind( sind(tx)/cosd(ty) ) = asind( rx/cosd( asind(ry) )
ty = asind( sind(ty)/cosd(tx) ) = asind( ry/cosd( asind(rx) )
MODIFICATION HISTORY:
JAN-2004, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
[Previous]
[Next]
NAME:
smei_hdr_flag
PURPOSE:
Manipulate binary flags in SMEI header
CATEGORY:
gen/for/lib
CALLING SEQUENCE:
subroutine smei_hdr_flag(id,iflag,hdr)
INPUTS:
id integer 0: read all flags from iflag into hdr
1: write all flags from hdr into iflag
2: only read UCSD flags
3: only write UCSD flags
iflag integer
hdr(*) double precision SMEI frm header
OUTPUTS:
hdr(*) double precision updated heaer
CALLED BY:
smei_frm_fts_base, smei_frm_read, smei_frm_read_get_sdark
INCLUDE:
include 'smei_frm_hdr.h'
PROCEDURE:
MODIFICATION HISTORY:
MAR-2005, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
[Previous]
[Next]
NAME:
smei_hdr_quaternion
PURPOSE:
Extract quaternion from SMEI frame header
CALLING SEQUENCE:
subroutine smei_hdr_quaternion(hdr,id,qq)
INPUTS:
hdr(*) double precision
SMEI frame header
id integer =0: return Coriolis quaternion
=1: return sky-to-cam quaternion
=2: return cam-to-sky quaternion
OUTPUTS:
qq(4) double precision
Coriolis s/c or camera quaternion
CALLED BY:
smei_frm_fts_axis, smei_hdr_eph, smei_skyd_fts, smei_skyd_init, smei_skyd_make
smei_skyd_sky
INCLUDE:
include 'smei_frm_hdr.h'
CALLS: ***
quaternion_inverse, quaternion_multiply
SEE ALSO:
quaternion_rotate_xyz
PROCEDURE:
> For id=0 the quaternion qcoriolis stored in the frame header is returned.
This rotates vectors from equatorial sky coordinates to HAFB
spacecraft coordinates.
> Hardcoded in this procedure are quaternions qcam that rotate vectors
from HAFB spacecraft coordinates to HAFB camera coordinates.
> An additional hardcoded quaternion qucsd rotates vectors from HAFB
camera coordinates to UCSD camera coordinates.
> For id=1 these three quaternions are multiplied together to get
the quaternion qq1=qcoriolis*qcam*qucsd that rotates from equatorial sky
coordinates to UCSD camera coordinates,
i.e, if (rx,ry,rz) is a unit vector in equatorial sky coordinates then
call quaternion_rotate_xyz(qq1,rx,ry,rz)
will return (rx,ry,rz) in the UCSD camera frame.
> For id=2 the inverse quaternion qq2 of the id=1 quaternion is returned,
which rotates vectors from UCSD camera coordinate to equatorial sky
coordinates.
i.e, if (rx,ry,rz) is a unit vector in the UCSD camera frame then
call quaternion_rotate_xyz(qq2,rx,ry,rz)
will return (rx,ry,rz) in the equatorial frame.
MODIFICATION HISTORY:
DEC-2004, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
[Previous]
[Next]
NAME:
smei_hdr_str
PURPOSE:
Extract character quantities from SMEI frame header
CALLING SEQUENCE:
subroutine smei_hdr_str(id, hdr, chdr)
INPUTS:
id integer abs(id): entry for char entry in SMEI header
(see smei_frm_hdr.h)
if id > 0 a string is extracted from hdr
if id < 0 a string is entered into hdr
hdr(*) double precision SMEI frame header
chdr character*(*) id < 0: string to be put in header
OUTPUTS:
chdr character*(*) id > 0: sting extracted from header
CALLED BY:
smei_base, smei_cal_bin, smei_frm_fts, smei_frm_fts_base, smei_frm_read
smei_frm_read_get_sdark, smei_orb, smei_skyd
INCLUDE:
include 'smei_frm_hdr.h'
MODIFICATION HISTORY:
JUN-2004, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
[Previous]
[Next]
NAME:
smei_hdr_time
PURPOSE:
Extract time from SMEI frame header
CALLING SEQUENCE:
subroutine smei_hdr_time(hdr,time)
INPUTS:
hdr(*) double precision SMEI frame header
OUTPUTS:
time(2) integer frame time
CALLED BY:
smei_cal_bin, smei_frm_fts, smei_frm_fts_eph, smei_frm_read
smei_frm_read_get_sdark, smei_hdr_eph, smei_skyd_fts, smei_skyd_init
smei_skyd_make, smei_skyd_sky
INCLUDE:
include 'smei_frm_hdr.h'
CALLS:
Time2HMS, Time2YDoy
PROCEDURE:
MODIFICATION HISTORY:
DEC-2004, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
[Previous]
[Next]
NAME:
smei_inside_fov
PURPOSE:
Check whether CCD location is inside FOV
CALLING SEQUENCE:
logical function smei_inside_fov(icam,mode,dfov,dr,phi)
INPUTS:
id integer id=0: CCD pixel coord to camera sky coord
id=1: camera sky coord to CCD pixel coord
icam integer camera id (1,2,3)
mode integer mode (0,1,2)
dfov(4) double precision modification to fov
dfov(1) < 0 added to inner radius (pixels)
dfov(2) > 0 added to outer radius (pixels
dfov(3) < 0 added to left side of fov (deg)
dfov(4) > 0 added to right side of fov deg)
dr double precision radial distance to optical axis in
units of engineering mode pixels
phi double precision angle from optical axis in degrees
(usually dr,phi are output from smei_axis_cam
output from smei_ccd_cam)
OUTPUTS:
smei_inside_fov logical .TRUE. : location inside fov
.FALSE.: location outside fov
CALLED BY:
smei_skyd_fts, smei_skyd_init, smei_skyd_make, smei_skyd_sky
PROCEDURE:
MODIFICATION HISTORY:
FEB-2006, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
[Previous]
[Next]
NAME:
smei_min_time
PURPOSE:
Time of minimum pattern.
CATEGORY:
ucsd/camera/for/lib
CALLING SEQUENCE:
entry smei_orb_min_time(TTime)
INPUTS:
(none)
OUTPUTS:
TTime(2) integer time of minimum pattern
CALLS:
TimeSplit
PROCEDURE:
Entry point in smei_orb_read.
MODIFICATION HISTORY:
JUN-2004, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
[Previous]
[Next]
NAME:
smei_orb
PURPOSE:
Determines minimum pattern for a reference orbit.
Then uses the miminimum pattern to create difference patterns for
all orbits in a specified period.
CALLING SEQUENCE:
program smei_orb
INPUTS:
(SMEI frames from SMEI data base)
Input from command line (see smei_foreign):
min_orbit integer extracted from
minimum=<min_orbit> or minimum=<YYYY_DOY_hhmmss>
orbit to be used for calculating the mimimum pattern
in smei_orb.
beg_orbit integer extracted from
start=<start_orbit> or start=<YYYY_DOY_hhmmss>
The start time of the first orbit for which a
difference orbital pattern is calculated.
end_orbit integer extracted from
stop=<end_orbit> or stop=<YYYY_DOY_hhmmss>
The iend time of the last orbit for which a minimum
orbital pattern is calculated.
(so if an orbit number n is specified, then orbit
n-1 is the last orbit processed)
norbit integer extracted from
orbits=<orbits>
Alternative to end_orbit: # orbits processed starting
at start_orbit.
fraction(2) real extracted from lowfraction=lowfraction and
highfraction=highfraction respectively
two fractions of one defining the part of the orbit
used for the orbital minimum and difference patterns.
if fraction(1) < fraction(2) then only the part of the
orbit with fraction(1) <= orbitfraction <= fraction(2)
is used.
if fraction(1) > fraction(2) then only the beginning part
of the orbit with orbitfraction < fraction(2) and the trailing
part with orbitfraction >= fraction(2) is used.
OUTPUTS:
One mimimum pattern, many difference patterns.
INCLUDE:
include 'dirspec.h'
include 'filparts.h'
include 'openfile.h'
include 'ftspar.h'
include 'smei_frm_layout.h'
include 'smei_frm_hdr.h'
include 'smei_frm_hdrok.h'
CALLS: ***
ArrI4Copy, ArrR4Bad, ArrR4Constant, ArrR4Copy, BadI4, Dbl2Str, FTCLOS, FTNOPN, FTUKYS
ForeignArgSet, ForeignI4Arg, Int2Str, SMEI_FRM_READ_SET_SDARK, SMEI_ORB_DIFF, Say
Str2Str, Time2Str, cDbl2Str, cHideLogical, cInt2Str, iFreeLun, iGetFileSpec, iGetLun
iOSSpawnCmd, iSetFileSpec, itrim, say_fts, smei_Time2Split, smei_cal_get
smei_cal_init, smei_foreign, smei_frm_c3mask_active, smei_frm_clean
smei_frm_get, smei_frm_mode, smei_frm_ok, smei_frm_read, smei_hdr_str
smei_orb_min, smei_orb_write, smei_orbit2, smei_orbit_time2
RESTRICTIONS:
The first frame in the minimum orbits determines which cal pattern
is used for the rest of the run, and what the setting of the C3
mask flag is.
PROCEDURE:
Fractions for May 2003: 0.5682, 0.1857
Fractions for Oct 2003: 0.8694, 0.6398 (1325.0/1524, 975.0/1524)
EXAMPLE:
smei_orb -min=2035 -start=2035 -stop=2221 -destination=$TUB
-lowfraction=0.5682 -highfraction=0.1857
MODIFICATION HISTORY:
MAR-2004, Andrew Buffington (UCSD/CASS; abuffington@ucsd.edu)
Note that "headroom" and small-scale FF are turned OFF when
camera 3 in 2x2 mode as here. Another consequence of this is
that columns 11 and 631 are NOT half stamped out as would be
the case if the SSFF were imposed. Thus these have a full
amount of pedestal and dark current, but only an unknown and
variable-with-row fraction of sky between 0.5 and unity. Yuck!
AUG-2004, Paul Hick (UCSD/CASS)
Rewrite based on Andys pattern_get_cam3.for
AUG-2005, Paul Hick (UCSD/CASS); V1.01
Added code to update Fits header of individual frames with
name of difference pattern (the program version number is
coded into the comment string.
Added extra map to each orbital file containing for each pixel
the orbital fraction of the frame used to fill it.
JUL-2006, Paul Hick (UCSD/CASS); V3.01
Added Fits keywords SMEI_ORB and CREATED to output files.
MAR-2007, Paul Hick (UCSD/CASS); V4.00
Modified to cope with "bad pixel" masks.
The first frame of an orbit now sets both the name of the
"closed shutter" pattern and the flag that decides whether
or not a "bad pixel" mask is in effect.
JUN-2007, Paul Hick (UCSD/CASS); V4.10
Fixed bug in smei_frm_read, introduced in V4.00
The orbital pattern would have been wrong for orbits with
flat_enabled=0 during periods when a "bad-pixel" mask was
onboard. The first time this happens is after 2007_133.
Since these orbits have not been run yet, no harm done.
SEP-2008, Paul Hick (UCSD/CASS); V4.12
Added command line argument sdark, and added call to
smei_frm_read_set_sdark.
OCT-2008, Paul Hick (UCSD/CASS; pphick@ucsd.edu); V4.13
Modications to smei_frm_c3mask_active in handling
transitions between mask. Added new mask
[Previous]
[Next]
NAME:
smei_orb_cal_name
PURPOSE:
Name of closed shutter calibration pattern on which the
orbital pattern is based.
CATEGORY:
ucsd/camera/for/lib
CALLING SEQUENCE:
entry smei_orb_cal_name(cPat)
INPUTS:
(none)
OUTPUTS:
cPat*(*) character name of calibration pattern
CALLS: ***
FTCLOS, FTGISZ, FTGKYD, FTGKYJ, FTGKYL, FTGKYS, FTGPVE, FTNOPN, Say, iFreeLun, iGetLun
say_fts, smei_Time2Split
CALLED BY:
smei_orb_get
PROCEDURE:
Entry point in smei_orb_read.
MODIFICATION HISTORY:
JUN-2004, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
[Previous]
[Next]
NAME:
smei_orb_camera
PURPOSE:
Camera ID of orbital pattern.
CATEGORY:
ucsd/camera/for/lib
CALLING SEQUENCE:
entry smei_orb_camera(icam)
INPUTS:
(none)
OUTPUTS:
icam integer camera ID of orbital pattern
CALLS: ***
FTCLOS, FTGISZ, FTGKYD, FTGKYJ, FTGKYL, FTGKYS, FTGPVE, FTNOPN, Say, iFreeLun, iGetLun
say_fts, smei_Time2Split
PROCEDURE:
Entry point in smei_orb_read.
MODIFICATION HISTORY:
JUN-2004, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
[Previous]
[Next]
NAME:
smei_orb_get
PURPOSE:
Select orbital minimum or difference pattern
CATEGORY:
ucsd/camera/for/lib
CALLING SEQUENCE:
subroutine smei_orb_get(orb_file,icam,mode,cal_file,orb_pattern,bNew,version)
INPUTS:
orb_file character*(*) name of orbital difference file
Only file name; no directory, no extension, i.e.
as extracted from Fits header of SMEI frame.
If orb_file is a blank string then orb_pattern is
set to zero.
icam integer must be always 3
mode integer must be always 1
cal_file character*(*) File name of closed shutter calibration pattern.
OUTPUTS:
orb_pattern real
bNew logical .TRUE. if a new orbital difference pattern is read
(and orb_pattern was modified)
.FALSE. if no new pattern is read (and orb_pattern
is not modified)
version double precision Version number of smei_orb that wrote the
the orbital pattarn. Return 0.0d0 if no orbital
pattern was read.
CALLED BY:
smei_skyd_fts, smei_skyd_init, smei_skyd_make, smei_skyd_sky
INCLUDE:
include 'filparts.h'
include 'dirspec.h'
include 'smei_frm_layout.h'
CALLS: ***
ArrR4Zero, Say, iFilePath, iGetFileSpec, iSearch, iSetFileSpec
smei_frm_read_get_sdark, smei_orb_cal_name, smei_orb_read, smei_orb_version
PROCEDURE:
The name of the last difference pattern is saved internally.
A new difference pattern is read only if the input orb_file is different from
the internally saved name. If a new file is read then orb_pattern is updated,
and bNew is set true. If no new file is read then orb_pattern is not modified.
and bNew is set false.
If the input cal_file is not the blank string then it is compared against the
the name of the calibration patterns associated with the current difference
pattern. If the names do not match program execution terminates.
MODIFICATION HISTORY:
SEP-2005, Paul Hick (UCSD/CASS)
JAN-2008, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
Added version argument.
[Previous]
[Next]
NAME:
smei_orb_min
PURPOSE:
Accumulate minimum orbital pattern
CATEGORY:
ucsd/camera/for/lib
CALLING SEQUENCE:
subroutine smei_orb_min(nsec,nx,ny,frame,ip_min,ip_frac,orb_pattern,ped_val,dark_scale,cal_pattern)
INPUTS:
nsec integer number of seconds into orbit
nx integer horizontal frame size
ny integer vertical frame size
frame(*) real frame data (after massaging by smei_frm_clean)
orb_pattern(*) real pattern to be updated.
Should be initialized to BadR4 by caller.
ped_val real pedestal value (from smei_frm_ped)
dark_scale real scaling factor for calibration patttern
cal_pattern(*) real closed shutter calibration pattern
OUTPUTS:
orb_pattern(*) real updated orbital minimum pattern
CALLED BY:
smei_orb
INCLUDE:
include 'smei_frm_layout.h'
RESTRICTIONS:
CALLS: ***
BadR4, smei_frm_mode
SEE ALSO:
PROCEDURE:
MODIFICATION HISTORY:
JUN-2004, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
[Previous]
[Next]
NAME:
smei_orb_min_name
PURPOSE:
Name of minimum pattern from on which the orbital pattern
is based.
CATEGORY:
ucsd/camera/for/lib
CALLING SEQUENCE:
entry smei_orb_min_name(cPat)
INPUTS:
(none)
OUTPUTS:
cPat*(*) character name of minimum pattern
CALLS: ***
FTCLOS, FTGISZ, FTGKYD, FTGKYJ, FTGKYL, FTGKYS, FTGPVE, FTNOPN, Say, iFreeLun, iGetLun
say_fts, smei_Time2Split
PROCEDURE:
Entry point in smei_orb_read.
MODIFICATION HISTORY:
JUN-2004, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
[Previous]
[Next]
NAME:
smei_orb_min_number
PURPOSE:
Orbit number of minimum pattern.
CATEGORY:
ucsd/camera/for/lib
CALLING SEQUENCE:
entry smei_orb_min_number(n)
INPUTS:
(none)
OUTPUTS:
n integer orbit number of orbital pattern
CALLS: ***
FTCLOS, FTGISZ, FTGKYD, FTGKYJ, FTGKYL, FTGKYS, FTGPVE, FTNOPN, Say, iFreeLun, iGetLun
say_fts, smei_Time2Split
PROCEDURE:
Entry point in smei_orb_read.
MODIFICATION HISTORY:
JUN-2004, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
[Previous]
[Next]
NAME:
smei_orb_mkname
PURPOSE:
Constructs file name of for orbital "on-the-fly" pattern
CATEGORY:
gen/for/lib/cal
CALLING SEQUENCE:
subroutine smei_orb_mkname(tt,cname)
INPUTS:
tt(2) integer time on which to base the filename
Should be the first frame
in an orbit
OUTPUTS:
cname*(*) character name of orbital pattern
in format c3orb_YYYY_hhmmss
(i.e. NO extension)
CALLS: ***
Str2Str, Time2Str, smei_orbit2, smei_orbit_time2
CALLED BY:
smei_base, smei_orb_write
INCLUDE:
include 'smei_frm_layout.h'
RESTRICTIONS:
Both smei_base and smei_orb call this routine.
smei_base uses it to set the expected name of the orbital pattern
for a camera 3 frame and adds it to the header of the frame.
smei_orb uses it when it creates the orbital pattern.
The names in smei_base and smei_orb MUST match. If they do not
then smei_skyd will not be able to produce skymaps (it will
abort).
Both programs pass the time for the first frame into an orbit
to this subroutine.
Note that smei_orb has a keyword that will force an update of
the frame headers with the name of orbital patterns it creates.
This is a more foolproof way of setting the orbital pattern
name, but also makes smei_orb a lot slower since all frames
need to be rewritten (unzip,read,update header,write,zip for
every frame).
PROCEDURE:
The time in the file name is the start time
(rounded to the nearest second) of the orbit of which
tt is part.
MODIFICATION HISTORY:
APR-2007, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
[Previous]
[Next]
NAME:
smei_orb_name
PURPOSE:
Pattern name of last pattern read with smei_orb_read
CATEGORY:
ucsd/camera/for/lib
CALLING SEQUENCE:
entry smei_orb_name(cPat)
INPUTS:
(none)
OUTPUTS:
cPat*(*) character name of orbital pattern
CALLS: ***
FTCLOS, FTGISZ, FTGKYD, FTGKYJ, FTGKYL, FTGKYS, FTGPVE, FTNOPN, Say, iFreeLun, iGetLun
say_fts, smei_Time2Split
PROCEDURE:
Entry point in smei_orb_read.
MODIFICATION HISTORY:
JUN-2004, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
[Previous]
[Next]
NAME:
smei_orb_number
PURPOSE:
Orbit number of orbital pattern.
CATEGORY:
ucsd/camera/for/lib
CALLING SEQUENCE:
entry smei_orb_number(n)
INPUTS:
(none)
OUTPUTS:
n integer orbit number of orbital pattern
CALLS: ***
FTCLOS, FTGISZ, FTGKYD, FTGKYJ, FTGKYL, FTGKYS, FTGPVE, FTNOPN, Say, iFreeLun, iGetLun
say_fts, smei_Time2Split
PROCEDURE:
Entry point in smei_orb_read.
MODIFICATION HISTORY:
JUN-2004, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
[Previous]
[Next]
NAME:
smei_orb_read
PURPOSE:
Read orbital difference pattern
CATEGORY:
ucsd/camera/for/lib
CALLING SEQUENCE:
subroutine smei_orb_read(cFile, nx, ny, orb_pattern)
INPUTS:
cFile*(*) character fully qualified Fits file name
OUTPUTS:
nx integer horizontal frame size
ny integer vertical frame size
orb_pattern(nx,ny) real pattern
CALLED BY:
smei_orb_get
INCLUDE:
include 'filparts.h'
include 'ftspar.h'
include 'smei_frm_layout.h'
CALLS: ***
FTCLOS, FTGISZ, FTGKYD, FTGKYJ, FTGKYL, FTGKYS, FTGPVE, FTNOPN, Say, iFreeLun, iGetLun
say_fts, smei_Time2Split
PROCEDURE:
MODIFICATION HISTORY:
JUN-2004, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
[Previous]
[Next]
NAME:
smei_orb_time
PURPOSE:
Time of orbital pattern.
CATEGORY:
ucsd/camera/for/lib
CALLING SEQUENCE:
entry smei_orb_time(TTime)
INPUTS:
(none)
OUTPUTS:
TTime(2) integer time of calibration pattern
CALLS: ***
FTCLOS, FTGISZ, FTGKYD, FTGKYJ, FTGKYL, FTGKYS, FTGPVE, FTNOPN, Say, iFreeLun, iGetLun
say_fts, smei_Time2Split
PROCEDURE:
Entry point in smei_orb_read.
MODIFICATION HISTORY:
JUN-2004, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
[Previous]
[Next]
NAME:
smei_orb_version
PURPOSE:
Software version number of smei_orb
CATEGORY:
ucsd/camera/for/lib
CALLING SEQUENCE:
entry smei_orb_version(Version)
INPUTS:
(none)
OUTPUTS:
Version double precision version number
CALLS: ***
FTCLOS, FTGISZ, FTGKYD, FTGKYJ, FTGKYL, FTGKYS, FTGPVE, FTNOPN, Say, iFreeLun, iGetLun
say_fts, smei_Time2Split
CALLED BY:
smei_orb_get
PROCEDURE:
Entry point in smei_orb_read.
MODIFICATION HISTORY:
JAN-2008, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
[Previous]
[Next]
NAME:
smei_orb_write
PURPOSE:
Write orbital pattern file
CATEGORY:
ucsd/camera/for/lib
CALLING SEQUENCE:
subroutine smei_orb_write(version,bForce,bDiff,cDest,cPatCal,min_orbit,this_orbit,
& tfirst,tlast,tlow,thigh,nframe,nx,ny,ip_orb,ip_frac,orb_pattern,cthis_orbit)
INPUTS:
version double precision smei_orb version number
bForce logical .FALSE.: do not overwrite existing pattern (if a pattern
exists, execution is aborted).
.TRUE. : overwrite pattern (the existing pattern file
is deleted, and a new one is written)
bDiff logical .FALSE.: write minimum pattern
.TRUE. : write difference pattern
cDest*(*) character destination directory for orbit pattern files
cPatCal*(*) character name of closed shutter calibration pattern on which
the orbital pattern is based
min_orbit integer minimum orbit
this_orbit integer curent orbit (either minimum orbit or a difference orbit)
tfirst(2) integer time of first frame in orbit
tlast(2) integer time of last frame in orbit
tlow(2) integer start time of fraction of orbit used
thigh(2) integer end time of fraction of orbit used
nframe(2) integer nframe(1): # frames in orbit this_orbit
nframe(2): # frames used
nx integer horizontal dimension of orbital pattern
ny integer vertical dimension of orbital pattern
ip_orb integer
ip_frac integer
orb_pattern(*) real
OUTPUTS:
cthis_orbit*(*) character name of output file
CALLED BY:
smei_orb
INCLUDE:
include 'filparts.h'
include 'smei_frm_layout.h'
CALLS: ***
ArrR4Copy, ArrR4Mask, BadR4, FTCLOS, FTCRHD, FTINIT, FTPHPR, FTPKYE, FTPKYG, FTPKYJ, FTPKYS
FTPPRE, Say, Time2Str, Time2System, iFilePath, iFreeLun, iGetLun, iOSDeleteFile, itrim
say_fts, smei_orb_mkname
PROCEDURE:
How many bad values do we expect????
MODIFICATION HISTORY:
JUN-2004, Paul Hick (UCSD/CASS)
JUL-2006, Paul Hick (UCSD/CASS)
Added Fits keyword SMEI_ORB (version number) and CREATED
(time file is created).
APR-2007, Paul Hick (UCSD/CASS)
Added keyword IFRAME (number of frames used).
Pattern name determined from tfirst by calling smei_orb_mkname.
DEC-2007, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
Changed keyword CREATED to DATE (consistent with IDL)
[Previous]
[Next]
NAME:
smei_orbit2
PURPOSE:
Coriolis orbit number at specified time
CALLING SEQUENCE:
entry smei_orbit2(tt,iorbit,dorbit)
INPUTS:
tt(2) integer time
OUTPUTS:
iorbit integer Coriolis orbit number
dorbit double precision
Coriolis orbit fraction
CALLS: ***
ArrI4Copy, Say, Time2Add, Time2Day8, Time2Delta, smei_orbit_info2
CALLED BY:
smei_foreign, smei_orb, smei_orb_mkname, smei_skyd, smei_skyd_fts, smei_skyd_init
smei_skyd_make, smei_skyd_sky
PROCEDURE:
See smei_orbit_time2
MODIFICATION HISTORY:
JUN-2004, Paul Hick (UCSD/CASS)
JAN-2010, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
Added warning if iorbit goes beyond last orbit in smei_sgp4_orbits.txt
[Previous]
[Next]
NAME:
smei_orbit_info2
PURPOSE:
Return start times of SMEI orbits
CALLING SEQUENCE:
subroutine smei_orbit_info2(norbit_max,orbit0,norbit,torbit)
OUTPUTS:
orbit0 integer Coriolis orbit number
this number added to the array index of torbit
gives the corresponding orbit number
norbit integer number of orbits for which start times are
available
torbit(2,*) integer start times
CALLED BY:
smei_orbit2, smei_orbit_period2, smei_orbit_time2
INCLUDE:
include 'dirspec.h'
include 'filparts.h'
include 'openfile.h'
CALLS: ***
Say, Time2Split, bOpenFile, iFilePath, iFreeLun
PROCEDURE:
Reads data base file $EPHEM/smei/smei_sgp4_orbits.txt
MODIFICATION HISTORY:
JAN-2006, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
[Previous]
[Next]
NAME:
smei_orbit_period2
PURPOSE:
Coriolis orbital period
CALLING SEQUENCE:
entry smei_orbit_period2(iorbit,dorbit,porbit)
INPUTS:
orbit double precision
Coriolis orbit number
OUTPUTS:
smei_orbit_period2
double precision
orbital period in days
CALLS: ***
ArrI4Copy, Say, Time2Add, Time2Day8, Time2Delta, smei_orbit_info2
CALLED BY:
smei_skyd_fts, smei_skyd_init, smei_skyd_make, smei_skyd_sky
PROCEDURE:
See smei_orbit_time2
MODIFICATION HISTORY:
JUN-2004, Paul Hick (UCSD/CASS)
JAN-2010, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
Bug fix. Array index to torbit was not limited to valid range.
Added warning if iorbit goes beyond last orbit in smei_sgp4_orbits.txt
[Previous]
[Next]
NAME:
smei_orbit_time2
PURPOSE:
Returns time at which Coriolis was in specified orbit
CALLING SEQUENCE:
subroutine smei_orbit_time2(iorbit,dorbit,tt)
INPUTS:
iorbit integer Coriolis orbit number
dorbit double precision Coriolis orbit fraction
OUTPUTS:
tt(2) integer time at which Coriolis was at specified orbit
CALLS: ***
ArrI4Copy, Say, Time2Add, Time2Day8, Time2Delta, smei_orbit_info2
CALLED BY:
smei_foreign, smei_orb, smei_orb_mkname, smei_skyd, smei_skyd_fts, smei_skyd_init
smei_skyd_make, smei_skyd_sky
PROCEDURE:
MODIFICATION HISTORY:
JUN-2004, Paul Hick (UCSD/CASS)
MAR-2007, Paul Hick (UCSD/CASS)
Increased NORBIT_MAX from 20000 to 40000
JAN-2010, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
Added warning if iorbit goes beyond last orbit in smei_sgp4_orbits.txt
Increased NORBIT_MAX from 40000 to 50000
[Previous]
[Next]
NAME:
smei_sky_iread
PURPOSE:
Read one of the real*4 arrays in an orbital sky map
CATEGORY:
ucsd/camera/for/lib
CALLING SEQUENCE:
subroutine smei_sky_iread(cFile, mode, nx, ny, skymap, cx, cy, dd, ctype)
INPUTS:
cFile*(*) character fully qualified Fits file name
mode integer selects Fits extension
= 0: (used by smei_sky_read)
= 1: (used by smei_sky_read)
= 2: (used by smei_sky_read)
= 3:
= 4:
= 5:
= 6: (used by smei_sky_read)
= 7: (used by smei_sky_read)
= 8: (used by smei_sky_read)
= 9: (used by smei_sky_read)
=10: (used by smei_sky_read)
=11: (used by smei_sky_read)
=12: Bad pixel map
The equatorial map is 3600x1200; the polar maps 1600x1600.
all others are 720x360 arrays.
OUTPUTS:
nx,ny integer dimensions of sky map
If there is an open error (usually because the file does not
exist) then nx=0 and ny=0 is returned.
skymap(nx,ny) integer sky map
cx,cy,dd double precision
constants relating array index to RA and dec.
For north polar map:
i=cx+dd*RA*cos(90-decl); j=cy+dd*RA*sin(90-decl)
For south polar map:
i=cx+dd*RA*cos(90+decl); j=cy+dd*RA*sin(90+decl)
For all other (equatorial) maps:
i=cx+dd*RA; j=cy+dd*decl
ctype character*(*) string describing data
INCLUDE:
include 'smei_frm_layout.h'
include 'filparts.h'
include 'ftspar.h'
CALLS: ***
FTCLOS, FTGISZ, FTGKYS, FTGPVJ, FTMAHD, FTNOPN, Say, iFreeLun, iGetLun, say_fts
SEE ALSO:
smei_htm_fts
PROCEDURE:
MODIFICATION HISTORY:
FEB-2005, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
[Previous]
[Next]
NAME:
smei_sky_read
PURPOSE:
Read one of the real*4 arrays in an orbital sky map
CATEGORY:
ucsd/camera/for/lib
CALLING SEQUENCE:
subroutine smei_sky_read(cFile, mode, nx, ny, skymap, cx, cy, dd, ctype)
INPUTS:
cFile*(*) character fully qualified Fits file name
Sky maps:
mode integer selects Fits extension
= 0: Equatorial map, RA=[0,360],DEC=[-60,+60]
= 1: Polar projection of north pole, DEC=[+50,+90]
= 2: Polar projection of south pole, DEC=[-50,-90]
= 3: (smei_sky_iread) Counts for equatorial map, RA=[0,360],DEC=[-60,+60]
= 4: (smei_sky_iread) Counts for map of north pole, DEC=[+50,+90]
= 5: (smei_sky_iread) Counts for map of south pole, DEC=[-50,-90]
= 6: Dirty sky brightness RA=[0,360],DEC=[-90,+90]
= 7: Time (fraction of orbit) RA=[0,360],DEC=[-90,+90]
= 8: PSF position angle from north RA=[0,360],DEC=[-90,+90]
= 9: PSF position angle from equinox RA=[0,360],DEC=[-90,+90]
=10: Discarded response map RA=[0,360],DEC=[-90,+90]
=11: Discarded triangles RA=[0,360],DEC=[-90,+90]
=12: Theta-x for glare removal
=13: Theta-y for glare removal
=14: Time (secs since TORIGIN)
=15: Direction cosine angle-x
=16: Contributing pixel count
Equ maps:
mode integer selects Fits extension
= 0: Equatorial map, RA=[0,360],DEC=[-60,+60]
= 1: Polar projection of north pole, DEC=[+50,+90]
= 2: Polar projection of south pole, DEC=[-50,-90]
= 3: Equatorial map, RA=[0,360],DEC=[-60,+60] (flat)
= 4: Polar projection of north pole, DEC=[+50,+90] (flat)
= 5: Polar projection of south pole, DEC=[-50,-90] (flat)
= 6: Stars removed from equator, RA=[0,360],DEC=[-60,+60]
= 7: Stars removed from north pole, DEC=[+50,+90]
= 8: Stars removed from south pole, DEC=[+50,+90]
= 9: Time (fraction of orbit) RA=[0,360],DEC=[-90,+90]
=10: Time (sec since TORIGIN) RA=[0,360],DEC=[-90,+90]
=11: Direction cosine angle-x RA=[0,360],DEC=[-90,+90]
=12: Contributing pixel count RA=[0,360],DEC=[-90,+90]
The equatorial map is 3600x1200; the polar maps 800x800.
all others are 720x360 arrays.
OUTPUTS:
nx,ny integer dimensions of sky map
If there is an open error (usually because the file does not
exist) then nx=0 and ny=0 is returned.
skymap(nx,ny) real sky map
cx,cy,dd double precision
constants relating array index to RA and dec.
For north polar map:
i=cx+dd*RA*cos(90-decl); j=cy+dd*RA*sin(90-decl)
For south polar map:
i=cx+dd*RA*cos(90+decl); j=cy+dd*RA*sin(90+decl)
For all other (equatorial) maps:
i=cx+dd*RA; j=cy+dd*decl
ctype character*(*) string describing data
INCLUDE:
include 'smei_frm_layout.h'
include 'filparts.h'
include 'ftspar.h'
CALLS: ***
FTCLOS, FTGISZ, FTGKYD, FTGKYS, FTGPVE, FTMAHD, FTNOPN, Say, iFreeLun, iGetLun, say_fts
SEE ALSO:
smei_htm_fts
PROCEDURE:
MODIFICATION HISTORY:
JAN-2005, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
[Previous]
[Next]
NAME:
smei_skyd
PURPOSE:
Creates skymaps from individual SMEI data frames
CATEGORY:
camera/for/sky
CALLING SEQUENCE:
program smei_skyd
INPUTS:
Input is controlled by command line arguments (see PROCEDURE).
<Pattern-file> file with pattern
default: $DAT/smei/testcase/DATA_SMEI/c2pat_2004_140.grd
use SMEIDB? to get pattern from SMEI data base
OPTIONAL INPUTS:
-source=<source>directory where the SMEI frames are located
default: SMEIDB? (the SMEI data base)
-destination=<destination>
directory where the output files are written.
default: $TUB
-help print some instructions and exit.
-firstorbit=<value> default: 7223
-lastorbit=<value> default: 7224
Orbits firstorbit through lastorbit are processed
-lowfraction=<value> default: 0.0
-highfraction=<value> default: 1.0
Only frames inside orbitfraction range
[lowfraction,highfraction] are used
(highfraction MUST be larger than lowfraction).
-camera=<value> camera to be processed
default: 2
-mode=<value> frame mode to be processed
default: 2 for cameras 1 and 2; 1 for camera 3
-level=<value> frame mode to be processed
default: 2
-grd output .grd files in addition to Fits file.
-keepglare do not remove glare
-overwrite create a new skymap if the Fits file already exists
-checkversion create a new skymap if the Fits file already exists,
but only if it has a lower version number.
(if -overwrite is set then -checkversion is ignored)
-version
-dumpversion
-avoidmoon
-avoidmoon=tx1,tx2,ty1,ty2
-avoidvenus=tx1,tx2,ty1,ty2
-avoidsun=tx1,tx2,ty1,ty2
OUTPUTS:
INCLUDE:
include 'dirspec.h'
include 'openfile.h'
include 'filparts.h'
include 'smei_frm_layout.h'
include 'smei_frm_hdr.h'
include 'smei_frm_hdrok.h'
include 'smei_skyd_dim.h'
CALLS: ***
ArrI4Copy, ArrR8Bad, BadI4, BadR4, Dbl2Str, ForeignArgSet, ForeignI4Arg, Int2Str
SMEI_FRM_READ_SET_SDARK, Say, Str2Str, Time2Str, bOpenFile, cDbl2Str, cInt2Str
iFreeLun, iGetFileSpec, iHideLogical, iOSDeleteFile, iScratchLun, iSetFileSpec
smei_cal_init, smei_foreign, smei_frm_getlist, smei_frm_ok, smei_frm_read
smei_hdr_str, smei_orbit2, smei_orbit_time2, smei_skyd_fts, smei_skyd_init
smei_skyd_make, smei_skyd_sky
EXAMPLE:
To run the testcase:
smei_skyd $DAT/smei/testcase/DATA_SMEI
PROCEDURE:
> A call to smei_skyd has the structure:
smei_skyd <List-file> <Pattern-file> <Frame-dir> <Output-dir>
-keyword1=<value1> -keyword2=<value2> ....
> Large-scale flatfields are read from $SMEIDB/flatfield (one of
c1_clsff.fts.gz, c2_clsff.fts.gz or c3_clsff.fts.gz.
Old HTM grid versus new equatorial/polar grid
---------------------------------------------
The linear dimension of pixels on the sky is ~0.05*2^mode (so 0.05,
0.1 and 0.2 degrees for mode 0,1,2, respectively). Or in terms of area
on the sky 9*4^mode, or 9,36 and 144 arcmin^2 for mode 0,1,2.
The HTM grid was used at level 11 for mode 1,2 and at level 12 for mode 0.
The area of nodes in the HTM grid is 3 to 7.3 arcmin^2 at level 11, and
0.86 to 1.8 arcmin^2 at level 12.
The final skymaps have a basic resolution of 0.1 degrees on the sky or
36 arcmin^2 per skybin. This is level 1 in the new setup. Higher levels
are subdivisions of this grid, i.e. level n has bins with linear
dimension of 0.1/n degrees, or area 36/n^2 arcmin^2. So n=3 in the new
setup provides about the same resolution as HTM level 11, and level 5
is about the same as HTM level 12.
MODIFICATION HISTORY:
NOV-2004, Paul Hick (UCSD/CASS)
MAY-2005, Paul Hick (UCSD/CASS)
Added processing of command line keywords nped_min and ndark_min
to override the default test for accepting frames (based on setting
of flag by smei_base).
SEP-2005, Paul Hick (UCSD/CASS)
Camera 3 glare removal is now also done using the glare model
for the multiplier, instead of using a few constants.
NOV-2005, Paul Hick (UCSD/CASS), V2.0
Modified to use different glare maps for cameras 2 and 3.
NOV-2005, Paul Hick (UCSD/CASS), V2.1
Added another low resolution map to output file (fraction
of orbit in seconds since start of orbit).
The lowres maps for the 'glare angles' are now always calculated.
They used to be set zero if glare subtraction was suppressed.
All lowres maps for camera 2 are run through GridSphere2D to
fill holes near the equatorial poles.
DEC-2005, Paul Hick (UCSD/CASS), V2.11
Changed format of several entries in Fits header
Modified to deal with presence of -overwrite on cmd line
DEC-2005, Paul Hick (UCSD/CASS), V2.12
Added keyword MODE to Fits header
Added processing of keyword to force overwrite of
skymaps with a lower version number.
Added keyword IMG_TYPE to Fits header
JAN-2006, Paul Hick (UCSD/CASS), V3.00
Introduced new definition of orbit start times based on
spacecraft ephemeris data (see smei_sgp4_orbits.pro).
JAN-2006, Paul Hick (UCSD/CASS), V3.01
Added keyword nshutter_open_skip to enable skipping of
frames after the shutter opens (see smei_frm_ok).
JAN-2006, Paul Hick (UCSD/CASS), V4.0
Fixed bug in smei_skyd_sky (the slope of the background
near stars was incorrect due to a wrong array index).
Reduced memory footprint by only processing HTM nodes
on the sky near the frame being processed.
FEB-2006, Paul Hick (UCSD/CASS), V5.0
Removed JHU HTM grid.
JUN-2006, Paul Hick (UCSD/CASS), V5.1
Added smei_skyd_size subroutine to control size of votes arrays.
Added direction cosine angle in long dimension to skymap file.
Note that this changes the layout of the Fits skymap file.
JUN-2006, Paul Hick (UCSD/CASS), V5.2
Added hdrok array to store selection criteria for frames.
These are now added to the primary Fits header of the skymap.
JUL-2006, Paul Hick (UCSD/CASS)
Fixed error in some of the comments for the map description
keyword for the polar maps.
Added Fits keyword STIME and ETIME to extension containing the time
STIME in seconds since the first frame used (these were only specified
in the main header). STIME is the time origin for the array.
JUL-2006, Paul Hick (UCSD/CASS), V5.3
Added check for bad quaternions in smei_frm_ok (this is used to skip past
B-dot episodes during S/C anomalies, for instance).
Filled the 'bad pixel' map in smei_skyd_combine (this has been empty
since version 4.0).
OCT-2006, John Clover, Paul Hick (UCSD/CASS), V6.0
Fixed problem near seam of map where start and end of orbit meet.
The orientation of camera 2 at the start of the orbit
is now used to draw a reference great circle on the sky. Near this
boundary pixels are tested individually to decide whether they are
part of the current orbit and should be dropped in the skymap.
Introduced torigin to keep track of the time origin for the
lowres time map. This is added to the Fits header of the time
map as keyword TORIGIN (used to be STIME).
Times tfirstfrm and tlastfrm are assigned the time of the first
and last frame, respectively, for which at least one pixel was
dropped in the skymap. These are written into the main header
of the skymap as keywords STIME and ETIME.
Added extra extension to lowres maps containg nr of pixels
contributing to each lowres bin.
NOV-2006, Paul Hick (UCSD/CASS), V6.01
Bugfix in smei_frm_ok (exclusion zones for Sun, Moon and Venus
were not processed)
MAR-2007, Paul Hick (UCSD/CASS)
Added check for "bad pixel" mask presence for camera 3.
The "closed shutter" calibration pattern for camera 3 is different
depending on whether a "bad pixel" mask is in effect.
APR-2007, Paul Hick (UCSD/CASS), V6.1
Added keyword CLNEDGE, set to .FALSE.. Should be set .TRUE.
when straylight from sky just outside the fov is removed.
MAY-2007, Paul Hick (UCSD/CASS), V6.2
Added GridSphere calls to smooth low resolution maps
where only a few CCD pixels (< 3) contribute to a skybin.
MAY-2007, Paul Hick (UCSD/CASS), V6.21
Bug fix in smei_frm_read (was not picking up name of orbital
pattern).
MAY-2007, Paul Hick (UCSD/CASS), V6.22
Bug fix in smei_skyd_size (abort was skipped when memory pool
for votes was full).
JUN-2007, Paul Hick (UCSD/CASS), V6.23
Recompiled after bugfix in smei_frm_read.
JUL-2007, Paul Hick (UCSD/CASS), V6.24
Renamed Fits key SMEI_HTM to SMEI_SKY (software version number)
Added cmd line argument -c3mask (used for camera 3 in mode 1
only) to control selection of calibration pattern (without or
with "bad-pixel" mask taken into account.
DEC-2007, Paul Hick (UCSD/CASS)
For single orbit runs the exit code for a successful run is now
1 [new skymap (over)written] or 3 [no new skymap written, either
because there are zero frames in the orbit, or because a
a skymap existed already and was not overwritten].
For multiple orbits the exit code a successful run is always 1
(this also was the case for single orbit runs).
DEC-2007, Paul Hick (UCSD/CASS), V7.01
Replaced keywords CX*,CY*,D_* keywords by WCS keywords
CRPIX*, CDELT*. Added other WCS keywords to make the
headers WCS compliant: CRVAL*, CTYPE*, CUNIT*, RADESYS,
EQUINOX, MJD-OBS and (polar maps only) LONPOLE.
Added keyword BAD_DATA to headers for lowres maps.
Added keyword GAIN with camera gain based on time
set in MJD-OBS and TIME.
Changed keyword CREATED to DATE (consistent with IDL)
JAN-2008, Paul Hick (UCSD/CASS), V7.02
Added keywords SMEI_CAL and SMEI_ORB with version numbers
APR-2008, Paul Hick (UCSD/CASS), V7.03
Removed comma from comment string for Fits keyword MAP.
JUL-2008, Paul Hick (UCSD/CASS)
Decreased setting of iSilent passed to smei_frm_ok
SEP-2008, Paul Hick (UCSD/CASS), V7.04
Added cmd line argument sdark.
OCT-2008, Paul Hick (UCSD/CASS), V7.05
Modifications to handling of transitions of c3
"bad-pixel" masks (in smei_frm_c3mask_active).
NOV-2008, Paul Hick (UCSD/CASS; pphick@ucsd.edu), V7.06
Added default box for rejection of frames with Sun
too close to the optical axis (in smei_frm_ok).
JUN-2011, John Clover (UCSD/CASS), V7.07
No code change; the file $SMEIDB/starmask.fts.gz has been modified.
The previous version used the coordinate system used by Andy for
the grd files from which starmask.fts.gz derives. The SMEI sky
maps use a different reference frame. The conversion between the
two frames was supposed to be made in smei_mkstarmask.pro, but this
was done. The new version of starmask.fts.gz fixes this.
JUN-2011, Paul Hick (UCSD/CASS; pphick@ucsd.edu), V7.08
Changed the print statements in smei_skyd_combine. For a -quiet
setting less/equal 1 now all votes (both accepted and rejected)
are shown, alongside the final value for each skybin.
Also added cmd line keyword -nostarmask to disable use of
starmask.fts.gz, effectively disabling the correction for
'star-nibbling'.
[Previous]
[Next]
NAME:
smei_skyd_addvalue
PURPOSE:
Make sure that the values added together
are all about the same size
(i.e. do not add 0.5 and 359.5 but 0.5 and -0.5 for angles).
CALLING SEQUENCE:
subroutine smei_skyd_addvalue(val,dval,hit,sum)
INPUTS:
val real
dval real
hit real number of hits in bin so far
sum real accumulated value
OUTPUTS:
sum real update accumulated value
MODIFICATION HISTORY:
NOV-2005, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
[Previous]
[Next]
NAME:
smei_skyd_checkpix
PURPOSE:
Check location of pixel against reference camera frame
defining a great circle on the sky defining at the seam
between start and end of orbit
CATEGORY:
camera/for/sky
CALLING SEQUENCE:
logical function smei_skyd_checkpix(pfov,runit,qq_cam2cam_edge)
INPUTS:
pfov integer linear array index into CCD frame
runit(*) double precision
unit vector in current camera frame
qq_cam2cam_edge(*)
double precision
quaternion that rotates vectors from
current camera frame to reference frame
OUTPUTS:
smei_skyd_checkpix
logical see Procedure
CALLS: ***
quaternion_rotate_xyz
CALLED BY:
smei_skyd_fts, smei_skyd_init, smei_skyd_make, smei_skyd_sky
PROCEDURE:
The camera frame has z-axis along the optical axis, x-axis
along the long dimension of the fov, and y-axis along the
narrow dimension such that y increases with decreasing radius
on the CCD. Stars travel in the direction of decreasing y;
frames sweep the sky in the direction of increasing y.
The reference camera frame is defined by the nominal viewing
direction of camera 2 at the start of an orbit. The long
dimension of camera 2 defines a reference circle that is used
separate start and end of orbit.
If a pixel in any frame near start or end of the orbit has
a negative y than it is traveling towards the reference
circle; if it has positive y it is traveling away from it.
For frames near the start of an orbit negative y
(smei_skyd_checkpix=.FALSE.) means the pixel is part of the
previous orbit; positive y (smei_skyd_checkpix=.TRUE.)
means the pixel is part of the current orbit.
For frames near the end of an orbit negative y
(smei_skyd_checkpix=.FALSE.) means the pixel is still in the
current orbit; positive y (smei_skyd_checkpix=.TRUE.)
means the pixel is part of the next orbit.
MODIFICATION HISTORY:
OCT-2006, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
[Previous]
[Next]
NAME:
smei_skyd_combine
PURPOSE:
Combines in into a single value.
CATEGORY:
smei/camera/for/sky
CALLING SEQUENCE:
integer function smei_skyd_combine(iType,bKeepGlitch,iSilent,level,node_id,count,val,flag,pos,rgood,rbad,badpix)
!integer function smei_skyd_combine(iType,bKeepGlitch,iSilent,count,val,flag,rgood,rbad,badpix)
INPUTS:
iType integer defines type of final response
0: Mean
1: Median
2: Mean/median (ratio)
3: Mean-median (difference)
4: Standard deviation
5: Median/std (ratio)
bKeepGlitch logical suppress glitch removal
iSilent integer higher values suppress more informational messages
count integer number of votes
level integer
node_id integer
val(*) real response for all votes
flag(*) integer*1 bitwise flags (e.g. the 'near star' flag)
pos(*) integer linear array index for the originating SMEI frame
for each vote
badpix(*) integer 'bad pixel' map
OUTPUTS:
smei_skyd_combine integer number of good votes from which final response
is calculated
rgood real final response for selected node,
calculated from all good votes
rbad real fraction of total adus in rejected votes: 1:nlow-1 where
too low; nhigh+1,count were too high
badpix(*) integer updated 'bad pixel' map
CALLED BY:
smei_skyd_fill, smei_skyd_flush, smei_skyd_sort
INCLUDE:
include 'filparts.h'
include 'smei_skyd_dim.h'
CALLS: ***
ArrR4Mean, ArrR4Median, ArrR4Stdev, ArrR4Total, BadR4, Flt2Str, IndexR4, Int2Str, Say
Str2Str, cInt2Str, smei_skyd_node2skyloc
PROCEDURE:
MODIFICATION HISTORY:
JAN-2006, Paul Hick (UCSD/CASS)
JUN-2011, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
Added arguments level and node_id (used in constructing diagnostic messages)
Made diagnostic messages more intelligible. All votes are now
printed if iSilent <=1.
[Previous]
[Next]
NAME:
smei_skyd_dim
PURPOSE:
Parameter definitions for sizes of skymaps
CALLING SEQUENCE:
include 'smei_skyd_dim.h'
INCLUDED BY:
smei_skyd, smei_skyd_combine, smei_skyd_fill, smei_skyd_node2sky
smei_skyd_node2skyloc, smei_skyd_pixel, smei_skyd_scan, smei_skyd_size
smei_skyd_sky
PROCEDURE:
Equatorial map covers [0,360] in RA and [-60,60] in declination
at 0.1 degree resolution.
The north and polar maps are polar maps out to 40 degrees from
the pole in two perpendicular directions with 0.1 degree resolution.
MODIFICATION HISTORY:
JAN-2006, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
[Previous]
[Next]
NAME:
smei_skyd_fill
PURPOSE:
Each pixel contributes to several nodes. These 'votes' are added
here to the pool of votes for all nodes.
CATEGORY:
smei/camera/for/sky
CALLING SEQUENCE:
subroutine smei_skyd_fill(iSilent,level,icam,mode,ra_pix,dec_pix,ipos,response,nflag)
INPUTS:
iSilent integer higher value suppresses more messages
level integer determines resolution of pool of nodes
(1 <= level <= SKYD__LEVEL=3
icam integer camera 1,2, or 3
mode integer mode 0,1 or 2
ra_pix (*) double precision RA for center and four corners of a pixel
dec_pix(*) double precision dec for center and four corners of a pixel
(passed to smei_skyd_pixel)
ipos integer linear array position of pixel in frame
response real CCD response for pixel
nflag integer bitwise flags
CALLS: ***
ArrI4Copy, ArrI4GetMinMax, BadR4, BadR8, Flt2Str, IndexI4, Int2Str, Say, Str2Str, cInt2Str
datan2d, dcosd, dsind, quaternion_rotate_xyz, smei_axis_cam, smei_skyd_combine
smei_skyd_node2sky, smei_skyd_pixel, smei_skyd_size
CALLED BY:
smei_skyd_fts, smei_skyd_init, smei_skyd_make, smei_skyd_sky
INCLUDE:
include 'filparts.h'
include 'smei_skyd_dim.h'
PROCEDURE:
The pool of nodes is maintaind in the node_* arrays.
All nodes in the first couple of frames are all put in pool 2
(with one vote for each node). These are the nodes that may be encountered
again in frames at the end of the orbit.
For subsequent frames, if the node is present already in pool 1 or 2 then
a vote is added to that node. New nodes are put in pool 1.
Nodes from pool 1 are removed if they move far enough outside the FOV.
After the last frame has been processed (and the skymap is complete),
both pools are cleared.
The node_sort array contains the indices needed to sort the node_* arrays
containing nodes up to and including contributions from the previous frame,
i.e. NOT YET the contribution from the frame currently being processed.
At the start node_sort(*) = n_nodes(SKYD__NODE_NTOP).
As pixels from the new frame are added the node_* arrays and
n_nodes(SKYD__NODE_NTOP) are updated; node_sort will be synchronized with
n_nodes(SKYD__NODE_NTOP) by skyd_sort prior to starting the next frame.
The implicit assumption is made that within a frame all triangles will have
different node names, i.e. NO NODE IS DUPLICATED WITHIN A FRAME.
MODIFICATION HISTORY:
JAN-2006, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
[Previous]
[Next]
NAME:
smei_skyd_fixvalue
PURPOSE:
Make sure value is in range [val_lo, val_hi]
CALLING SEQUENCE:
subroutine smei_skyd_fixvalue(val,val_lo,val_hi)
INPUTS:
val real
val_lo real
val_hi real
OUTPUTS:
val real
CALLED BY:
smei_skyd_fts, smei_skyd_init, smei_skyd_make, smei_skyd_sky
MODIFICATION HISTORY:
OCT-2006, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
[Previous]
[Next]
NAME:
smei_skyd_flush
PURPOSE:
Removes node that have moved outside the field of view from the
pool of nodes after depositing in on the equatorial and/or polar skymaps
CALLING SEQUENCE:
entry smei_skyd_flush(iType,bKeepGlitch,iSilent,level,icam,mode,qq,drfov_max,img,xmg,badpix,lowres)
INPUTS:
iType integer Passed to smei_skyd_combine to determine the statistical quantity.
possible values n=0,1,2,3,4,5. Set on cmd line using
-mean, -median or -type=n options.
bKeepGlitch logical Passed to smei_skyd_combine
Suppress glitch removal. Set with cmd line -keepglitch option
level integer
mode integer mode (0,1,2)
icam integer camera (1,2,3)
qq(*) double precision quaternion
drfov_max real
OUTPUTS:
xmg(*) real accumulated totals for equatorial map
img(*) real total counts for equatorial map
Passed to smei_skyd_node2sky which updates
them when nodes are complete
badpix(*) integer 'bad pixel' map for SMEI frame
Passed to smei_skyd_combine
lowres(SKYD__NXLO,SKYD__NYLO,SKYD__LO_NMAP)
CALLS: ***
ArrI4Copy, ArrI4GetMinMax, BadR4, BadR8, Flt2Str, IndexI4, Int2Str, Say, Str2Str, cInt2Str
datan2d, dcosd, dsind, quaternion_rotate_xyz, smei_axis_cam, smei_skyd_combine
smei_skyd_node2sky, smei_skyd_pixel, smei_skyd_size
CALLED BY:
smei_skyd_fts, smei_skyd_init, smei_skyd_make, smei_skyd_sky
PROCEDURE:
n_nodes integer n_nodes(SKYD__NODE_NTOP)
highest occupied index in pool arrays
updated to a lower value when empty slots
at the end of the pool are removed.
n_nodes(SKYD__NODE_NSLOT)
total number of nodes in pool
updated when nodes are removed
n_nodes(SKYD__NODE_NVOTE)
total number of votes in pool
update when nodes are removed
smei_skyd_flush is called in smei_skyd_sky prior to adding in the pixels
of the a new frame into the pool, i.e. the quaternion from the new
header is used to decided whether a node is inside/outside the fov.
MODIFICATION HISTORY:
FEB-2006, Paul Hick (UCSD/CASS)
JUN-2011, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
Added args level and node_id to call to smei_skyd_combine
[Previous]
[Next]
NAME:
smei_skyd_fnc
PURPOSE:
Function declarations for smei_sky
CATEGORY:
camera/for/sky
CALLING SEQUENCE:
include 'smei_skyd_fnc.h'
PROCEDURE:
MODIFICATION HISTORY:
JUN-2006, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
[Previous]
[Next]
NAME:
smei_skyd_fts
PURPOSE:
Writes orbital sky maps to FTS file
CATEGORY:
ucsd/camera/for/sky
CALLING SEQUENCE:
entry smei_skyd_fts(sky_version,forbit_ext,forbit_ltd,hdrok,nframe,iframe,ibreak)
CALLS: ***
ArrI4Copy, ArrI4Zero, ArrR4DivideByArrR4, ArrR4Mask, ArrR4PlusArrR4, ArrR4Zero
ArrR8Copy, BadR4, Dbl2Str, FTCLOS, FTCRHD, FTINIT, FTPHPR, FTPKYG, FTPKYJ, FTPKYL, FTPKYS
FTPPRB, FTPPRE, FTPPRJ, Flt2Str, ForeignArgSet, ForeignI4Arg, ForeignR8Arg
GridSphere2D, GridSphereRange, GridSphereWeight, Int2Str, SMEI_SKYD_PRINT
SMEI_SKYD_PRINT_NODES, SMEI_SKYD_SAVE, Say, Str2Str, Time2Day8, Time2Delta
Time2Differ, Time2HMS, Time2MJD, Time2Str, Time2System, Time2smei_quaternion
cInt2Str, dasind, datan2d, dcosd, dsind, iFilePath, iFreeLun, iGetFileSpec, iGetLun
iOSDeleteFile, iSearch, iSetFileSpec, itrim, quaternion_inverse
quaternion_multiply, quaternion_rotate_xyz, say_fts, smei_FitPlane
smei_axis_cam, smei_axis_ccd, smei_cal_get, smei_frm_c3mask_active
smei_get_glare, smei_get_lsff, smei_get_starmask, smei_hdr_quaternion
smei_hdr_time, smei_inside_fov, smei_orb_get, smei_orbit2, smei_orbit_period2
smei_orbit_time2, smei_skyd_checkpix, smei_skyd_fill, smei_skyd_fixvalue
smei_skyd_flush, smei_skyd_go, smei_skyd_scan, smei_skyd_sort
CALLED BY:
smei_skyd
PROCEDURE:
> Entry point in smei_skyd_sky.
> The equatorial maps use a linear scale to from array index i,j to ra,dec
i=1,nxeq, ra=[0,360), j=1,nyeq, dec=[-60,60)
i = cxeq+ra *d_eq ra = (i-cxeq)/d_eq
j = cyeq+dec*d_eq dec = (j-cyeq)/d_eq
> The polar maps use a polar transformation
i=1,nxeq, j=1,nyeq
i = cxpl+d_pl*(90-abs(dec))*cos(ra)
j = cypl+d_pl*(90-abs(dec))*sin(ra)
ra = atan( (j-cypl)/(i-cxpl) )
90-abs(dec) = sqrt( (i-cxpl)^2+(j-cypl)^2 )
> The equatorial map is written as primary data, the north and
south polar maps as first and second extension, respectively.
> Added entries to FTS header:
Ext 0 (equatorial map):
SMEI_SKY character smei_skyd software version number
DATE character File creation time
NAME character File name (no directory, no type)
CAMERA integer Camera
ORBIT double precision Orbit number
MAP character String describing map
CX double precision Array index for RA=0
CY double precision Array index for DEC=0
BD double precision Number of bins per degree
Ext 1 (north pole map)
MAP character String describing map
CX double precision Array index for north pole
CY double precision Array index for north pole
BD double precision Number of bins per degree
Ext 2 (south pole map)
MAP character String describing map
CX double precision Array index for south pole
CY double precision Array index for south pole
BD double precision Number of bins per degree
Note that the values for both poles are the same.
> After the high-resolution skymaps follow a group of (currently) six
low resolution maps:
Ext 3-8 ('dirty' sky brightness, time, psf orientation w.r.t. equatorial
north and w.r.t. vernal equinox, fraction of discarded response, and
fraction of bad nodes)
MAP character String describing map
CX double precision Array index for RA=0
CY double precision Array index for DEC=0
BD double precision Number of bins per degree
MODIFICATION HISTORY:
NOV-2004, Paul Hick (UCSD/CASS)
APR-2005, Paul Hick (UCSD/CASS)
New set of camera quaternions for cam 1 and 2.
Ad hoc corrections to tx and ty in smei_ccd2cam.
Added 'onesky' keyword.
Extra keyword ONEORBIT to identify orbital maps.
NOV-2005, Paul Hick (UCSD/CASS)
Modified to accepts different glare maps for cameras 2 and 3.
DEC-2005, Paul Hick (UCSD/CASS)
Modified to deal with presence of -overwrite on cmd line.
Added Fits keyword MODE.
Added processing of SMEI_HTM keyword for existing sky maps
to force overwrite of maps with lower version number.
APR-2007, Paul Hick (UCSD/CASS)
Added keyword CLNEDGE, set to .FALSE.. Should be set .TRUE.
when straylight from sky just outside the fov is removed.
JUL-2007, Paul Hick (UCSD/CASS)
Renamed key SMEI_HTM to key SMEI_SKY (for version number)
DEC-2007, Paul Hick (UCSD/CASS)
Replaced keywords CX*,CY*,D_* keywords by WCS keywords
CRPIX*, CDELT*. Added other WCS keywords to make the
header WCS compliant: CRVAL*, CTYPE*, CUNIT*, RADESYS,
EQUINOX, MJD-OBS and (polar maps only) LONPOLE.
Added keyword BAD_DATA to headers for lowres maps.
Added keyword GAIN with camera gain based on time
set in MJD-OBS and TIME.
APR-2008, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
Removed comma from comment string for keyword MAP
[Previous]
[Next]
NAME:
smei_skyd_go
PURPOSE:
Decide on whether to continue processing frames for given orbit
CALLING SEQUENCE:
logical function smei_skyd_go(bOverwrite,bCheckVersion,cFile,version,bExists)
INPUTS:
bOverwrite logical
bCheckVersion logical
cFile character*(*)
version double precision
OUTPUTS:
bExists logical
smei_skyd_go logical
CALLED BY:
smei_skyd_fts, smei_skyd_init, smei_skyd_make, smei_skyd_sky
INCLUDE:
include 'filparts.h'
include 'ftspar.h'
CALLS: ***
FTCLOS, FTGKYD, FTNOPN, Say, iFreeLun, iGetLun, iSearch, say_fts
PROCEDURE:
Called when the first good frame for an orbits has been found to decide
whether the orbit needs to be processed and a skymap is to be created.
> If the skymap does not exist then a skymap is created (bExists=.FALSE.;
smei_skyd_go=.TRUE.)
> If the skymap already exists then bOverwrite, bCheckVersion and version
determine what happens:
1. If bOverwrite is .TRUE. then the skymap is overwritten (bExists=.TRUE.,
smei_skyd_go=.TRUE.)
2. If bCheckversion is .TRUE. and version is larger than the version of
the skymap then the skymap is overwritten (bExists=.TRUE.;
smei_skyd_go=.TRUE.)
3. If bOverwrite=bCheckVersion=.FALSE. then the skymap is not overwritten
(bExists=.TRUE.; bGo=.FALSE.)
MODIFICATION HISTORY:
DEC-2005, Paul Hick (UCSD/CASS)
JUL-2007, Paul Hick (UCSD/CASS)
Added test for key SMEI_SKY in addition to check for now
obsolete key SMEI_HTM to determine version number.
NOV-2007, Paul Hick (UCSD/CASS)
Bug fix. istat was not reinitialized to zero after looking for
keyword SMEI_SKY. Bug reported by John Clover.
DEC-2007, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
Removed check for SMEI_HTM. Keyword is no longer present
in any of the skymaps on $SMEISKY0/sky.
[Previous]
[Next]
NAME:
smei_skyd_init
PURPOSE:
Initialize variables for smei_skyd_sky.
CALLING SEQUENCE:
entry smei_skyd_init(sky_version,icurrent_orbit,TLow,THigh,hdr,cVar,cArg,bGo)
INPUTS:
sky_version double precision smei_skyd version number
icurrent_orbit integer orbit number of the current orbit
being processed (the 'hdr' for the
the current frame might still belong
to the previous of next orbit).
hdr(*) double precision frame header array
cVar(*) character*(*) cVar(2): pattern file or SMEIDB?
cVar(4): output directory
cArg character*(*) command line keywords
OUTPUTS:
bGo logical bGo is returned .FALSE. only
if the first frame for a new skymap
is processed, and the Fits file for
the skymap already exists.
CALLS: ***
ArrI4Copy, ArrI4Zero, ArrR4DivideByArrR4, ArrR4Mask, ArrR4PlusArrR4, ArrR4Zero
ArrR8Copy, BadR4, Dbl2Str, FTCLOS, FTCRHD, FTINIT, FTPHPR, FTPKYG, FTPKYJ, FTPKYL, FTPKYS
FTPPRB, FTPPRE, FTPPRJ, Flt2Str, ForeignArgSet, ForeignI4Arg, ForeignR8Arg
GridSphere2D, GridSphereRange, GridSphereWeight, Int2Str, SMEI_SKYD_PRINT
SMEI_SKYD_PRINT_NODES, SMEI_SKYD_SAVE, Say, Str2Str, Time2Day8, Time2Delta
Time2Differ, Time2HMS, Time2MJD, Time2Str, Time2System, Time2smei_quaternion
cInt2Str, dasind, datan2d, dcosd, dsind, iFilePath, iFreeLun, iGetFileSpec, iGetLun
iOSDeleteFile, iSearch, iSetFileSpec, itrim, quaternion_inverse
quaternion_multiply, quaternion_rotate_xyz, say_fts, smei_FitPlane
smei_axis_cam, smei_axis_ccd, smei_cal_get, smei_frm_c3mask_active
smei_get_glare, smei_get_lsff, smei_get_starmask, smei_hdr_quaternion
smei_hdr_time, smei_inside_fov, smei_orb_get, smei_orbit2, smei_orbit_period2
smei_orbit_time2, smei_skyd_checkpix, smei_skyd_fill, smei_skyd_fixvalue
smei_skyd_flush, smei_skyd_go, smei_skyd_scan, smei_skyd_sort
CALLED BY:
smei_skyd
PROCEDURE:
Entry point in smei_skyd_sky.
MODIFICATION HISTORY:
NOV-2004, Paul Hick (UCSD/CASS)
DEC-2005, Paul Hick (UCSD/CASS)
Modified to deal with presence of -overwrite on cmd line
JUL-2007, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
Added check for cmd line argument -c3mask=0/1
Added argument ipick to smei_cal_get calls
[Previous]
[Next]
NAME:
smei_skyd_make
PURPOSE:
Takes the three node arrays (node, nodeid, and hits),
averages them and puts them into a two-dimensional skymap
CATEGORY:
camera/for/sky
CALLING SEQUENCE:
entry smei_skyd_make()
OUTPUTS:
Output goes to three equatorial .grd files, two polar .grd files
and a FTS file containing both equatorial and polar maps.
CALLS: ***
ArrI4Copy, ArrI4Zero, ArrR4DivideByArrR4, ArrR4Mask, ArrR4PlusArrR4, ArrR4Zero
ArrR8Copy, BadR4, Dbl2Str, FTCLOS, FTCRHD, FTINIT, FTPHPR, FTPKYG, FTPKYJ, FTPKYL, FTPKYS
FTPPRB, FTPPRE, FTPPRJ, Flt2Str, ForeignArgSet, ForeignI4Arg, ForeignR8Arg
GridSphere2D, GridSphereRange, GridSphereWeight, Int2Str, SMEI_SKYD_PRINT
SMEI_SKYD_PRINT_NODES, SMEI_SKYD_SAVE, Say, Str2Str, Time2Day8, Time2Delta
Time2Differ, Time2HMS, Time2MJD, Time2Str, Time2System, Time2smei_quaternion
cInt2Str, dasind, datan2d, dcosd, dsind, iFilePath, iFreeLun, iGetFileSpec, iGetLun
iOSDeleteFile, iSearch, iSetFileSpec, itrim, quaternion_inverse
quaternion_multiply, quaternion_rotate_xyz, say_fts, smei_FitPlane
smei_axis_cam, smei_axis_ccd, smei_cal_get, smei_frm_c3mask_active
smei_get_glare, smei_get_lsff, smei_get_starmask, smei_hdr_quaternion
smei_hdr_time, smei_inside_fov, smei_orb_get, smei_orbit2, smei_orbit_period2
smei_orbit_time2, smei_skyd_checkpix, smei_skyd_fill, smei_skyd_fixvalue
smei_skyd_flush, smei_skyd_go, smei_skyd_scan, smei_skyd_sort
CALLED BY:
smei_skyd
PROCEDURE:
> Entry point in smei_skyd_sky. See that procedure for more information.
MODIFICATION HISTORY:
April 2003, Aaron Smith (UCSD/CASS)
Updated to include capability for all sky imaging in 3 equatorial
plots, and two polar plots
[Previous]
[Next]
NAME:
smei_skyd_node2sky
PURPOSE:
Drop node on skymap (equatorial or polar maps)
CALLING SEQUENCE:
subroutine smei_skyd_node2sky(level,node_id,nvote,ngood,xgood,img,xmg)
INPUTS:
node_i integer
level integer
node_id integer
nvote integer (not used)
ngood integer (not used)
xgood real response of node (return value of
smei_skyd_combinevotes.
xmg(*) real accumulated totals for equatorial map
img(*) real total counts for equatorial map
OUTPUTS:
xmg(*) real updated sky map arrays
img(*) real
CALLED BY:
smei_skyd_fill, smei_skyd_flush, smei_skyd_sort
INCLUDE:
include 'smei_skyd_dim.h'
SEE ALSO:
smei_skyd_combine
PROCEDURE:
MODIFICATION HISTORY:
JAN-2006, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
[Previous]
[Next]
NAME:
smei_skyd_node2skyloc
PURPOSE:
Drop node on skymap (equatorial or polar maps)
CALLING SEQUENCE:
subroutine smei_skyd_node2skyloc(level,node_id,kp,ix,jy)
INPUTS:
node_i integer
level integer
node_id integer
OUTPUTS:
kp integer kp=0: equatorial map
kp=1: north pole map
kp=2: south pole map
ix integer array index in 1st dim
jy integer array index in 2nd dim
(ix,jy) is the array index into
a hires skymap array
CALLED BY:
smei_skyd_combine
INCLUDE:
include 'smei_skyd_dim.h'
SEE ALSO:
smei_skyd_combine
PROCEDURE:
MODIFICATION HISTORY:
JUN-2011, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
Extracted from smei_skyd_node2sky
[Previous]
[Next]
NAME:
smei_skyd_pixel
PURPOSE:
Construct list of nodes (skybins) to which a given pixel contributes
CATEGORY:
smei/camera/for/sky
CALLING SEQUENCE:
integer function smei_skyd_pixel(level,ra_pix,dec_pix,max_count,node_list)
INPUTS:
level integer determines resolution of pool of nodes
(1 <= level <= SKYD__LEVEL=3
ra_pix (0:4) double precision RA for center and four corners of a pixel
dec_pix(0:4) double precision dec for center and four corners of a pixel
max_count integer Max allowed number of nodes
OUTPUTS:
smei_skyd_pixel integer number of nodes on node_list
node_list(*) integer node id
CALLS: ***
Say, cInt2Str, dcosd, dsind, inside_area
CALLED BY:
smei_skyd_fill, smei_skyd_flush, smei_skyd_sort
INCLUDE:
include 'smei_skyd_dim.h'
PROCEDURE:
The name of a node is related to the linear array index into one
of the skymaps (equatorial, south and north pole).
The equatorial map has NEQ = (level*SKYD__NXEQ)*(level*SKYD__NYEQ) bins.
The two polar maps have NPL = (level*SKYD__NXPL)*(level*SKYD__NYPL) bins.
Each node corresponds to a skybin in these maps.
An equatorial node has node id 1 ... NEQ
An north polar node has node id NEQ+1 ... NEQ+NPL
A south polar node has node id NEQ+NPL+1 ... NEQ+2*NPL
Program execution is aborted if there are more than max_count nodes
MODIFICATION HISTORY:
FEB-2006, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
[Previous]
[Next]
NAME:
smei_skyd_scan
PURPOSE:
Extracts part of skymap inside box bounded in right ascension
and declination
CATEGORY:
camera/for/sky
CALLING SEQUENCE:
subroutine smei_skyd_scan(ra_min,ra_max,dec_min,dec_max,
& d_eq_,n_eq_,nxeq_,nyeq_,cxeq_,cyeq_,
& d_pl_,n_pl_,nxpl_,nypl_,cxpl_,cypl_, img,xmg)
INPUTS:
ra_min double precision minimum right ascension (deg) in [0,360]
ra_max double precision maximum right ascension (deg) in [0,360]
If ra_min > ra_max then RA=[ra_min,360]
and RA[0,ra_max] are extracted
dec_min double precision minimum declination
dec_max double precision maximum declination
xmg(*) real sky map
img(*) real sky map counts
OUTPUTS:
For the eqautorial map:
d_eq_ double precision bin size (skybins per degree)
n_eq_ integer nr of sky bins (=nxeq_*nyeq_)
nxeq_ integer nr of sky bins in RA direction
nyeq_ integer nr of sky bins in dec direction
cxeq_ double precision array index for RA=0
cyeq_ double precision array index for dec=0
For the polar maps:
d_pl_ double precision radial bin size (skybins per degree)
n_pl_(2) integer nr of sky bins in polar maps (=nxpl_*nypl_)
nxpl_(2) integer nr of sky bins in x-direction of polar map
nypl_(2) integer nr of sky bins in y-direction of polar map
cxpl_(2) double precision horizontal array index of pole
cypl_(2) double precision vertical array index of pole
xmg(*) real updated sky maps
img(*) real updated sky map counts
CALLS: ***
ArrR4Copy, Int2Str, Say, Str2Str, dcosd, dsind
CALLED BY:
smei_skyd_fts, smei_skyd_init, smei_skyd_make, smei_skyd_sky
INCLUDE:
include 'filparts.h'
include 'smei_skyd_dim.h'
PROCEDURE:
MODIFICATION HISTORY:
MAR-2006, Paul Hick (UCSD/CASS)
JUN-2011, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
Added print statements for pixel coordinates in full-sky map for the
the lower-left corner of the selected patch of sky.
[Previous]
[Next]
NAME:
smei_skyd_size
CATEGORY:
smei/camera/for/sky
CALLING SEQUENCE:
subroutine smei_skyd_size(iSilent,id,n_nodes,node_cnt,node_value,node_flag)
INPUTS:
iSilent integer higher value suppresses more messages
id integer 0: increase max number of votes allowed
1: increase max number of nodes allowed
n_nodes(SKYD__NODE_N)
integer pool statistics
node_cnt (SKYD__NODES) integer
node_value(SKYD__NODES) real
node_flag (SKYD__NODES) integer*1
pool arrays
CALLED BY:
smei_skyd_fill, smei_skyd_flush, smei_skyd_sort
INCLUDE:
include 'filparts.h'
include 'smei_skyd_dim.h'
CALLS: ***
ArrI4GetMinMax, Flt2Str, Int2Str, Say, Str2Str
MODIFICATION HISTORY:
MAR-2006, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
[Previous]
[Next]
NAME:
smei_skyd_sky
PURPOSE:
Indexes a frame of SMEI data.
CATEGORY:
camera/for/sky
CALLING SEQUENCE:
subroutine smei_skyd_sky(hdr,iframe,frame)
INPUTS:
hdr(*) double precision frame header
frame(*) real 2-D SMEI frame
OUTPUTS:
CALLED BY:
smei_skyd
IMPLICIT:
implicit none
INCLUDE:
include 'filparts.h'
include 'smei_frm_layout.h'
include 'smei_frm_hdr.h'
include 'smei_frm_hdrok.h'
include 'smei_skyd_dim.h'
CALLS: ***
ArrI4Copy, ArrI4Zero, ArrR4DivideByArrR4, ArrR4Mask, ArrR4PlusArrR4, ArrR4Zero
ArrR8Copy, BadR4, Dbl2Str, FTCLOS, FTCRHD, FTINIT, FTPHPR, FTPKYG, FTPKYJ, FTPKYL, FTPKYS
FTPPRB, FTPPRE, FTPPRJ, Flt2Str, ForeignArgSet, ForeignI4Arg, ForeignR8Arg
GridSphere2D, GridSphereRange, GridSphereWeight, Int2Str, SMEI_SKYD_PRINT
SMEI_SKYD_PRINT_NODES, SMEI_SKYD_SAVE, Say, Str2Str, Time2Day8, Time2Delta
Time2Differ, Time2HMS, Time2MJD, Time2Str, Time2System, Time2smei_quaternion
cInt2Str, dasind, datan2d, dcosd, dsind, iFilePath, iFreeLun, iGetFileSpec, iGetLun
iOSDeleteFile, iSearch, iSetFileSpec, itrim, quaternion_inverse
quaternion_multiply, quaternion_rotate_xyz, say_fts, smei_FitPlane
smei_axis_cam, smei_axis_ccd, smei_cal_get, smei_frm_c3mask_active
smei_get_glare, smei_get_lsff, smei_get_starmask, smei_hdr_quaternion
smei_hdr_time, smei_inside_fov, smei_orb_get, smei_orbit2, smei_orbit_period2
smei_orbit_time2, smei_skyd_checkpix, smei_skyd_fill, smei_skyd_fixvalue
smei_skyd_flush, smei_skyd_go, smei_skyd_scan, smei_skyd_sort
SEE ALSO:
smei_skyd_init, smei_skyd_make
PROCEDURE:
The photometric measurements from a single SMEI camera are combined
and then averaged to produce a surface-brightness sky map.
The "level" parameter governs the
granularity of the triangular coordinate frame. The coordinates of
the four corners of a pixel (or bin) are transformed down into this
frame, and the photometric surface brightness as measured by that
pixel is added to all nodes whose centers lie within the rectangle.
This surface brightness is corrected by 1/cosine of the pixels angle
to the camera axis, and by r/rad0 the pixels fractional distance to
the FOVs rotational center. When the data sequence is finished, all
triangle response sums are averaged and the resulting sky map binned
into an output surface brightness map.
MODIFICATION HISTORY:
2002,2003 Aaron Smith (UCSD/CASS)
2002->Original
2003->removed most C++ functions and re-wrote in fortran as subroutines
->add quaternion capabilities
DEC-2002, Paul Hick (UCSD/CASS)
Defined LEVEL and NMAX as parameters. NMAX is determined from LEVEL.
NMAX is then used to dimension arrays node, nodeid and hits
JAN-2003, Andrew Buffington (UCSD/CASS)
Integrated standard pedestal and dark current routines.
Rendered names compliant with those of B.V. Jackson
Incorporated 1/cosine surface-brightness correction for aperture
perspective (currently in smei_skyd_sky routine)
Incorporated large and small scale flatfield corrections
Incorporated FORTRAN read subroutine
Jan-May, 2003 Aaron Smith (UCSD)
note: not compliant with TMO data anymore
FEB-2005, Paul Hick (UCSD/CASS)
Reduced resolution of polar maps from 1600x1600 to 800x800.
Added theta-x and theta-y maps for glare removal as
low-resolution maps to Fits skymap.
NOV-2005, Paul Hick (UCSD/CASS)
Added another low resolution map to output file (fraction
of orbit in seconds since start of orbit).
The lowres maps for the 'glare angles' are now always calculated.
They used to be set zero if glare subtraction was suppressed.
All lowres maps for camera 2 are run through GridSphere2D to
fill holes near the equatorial poles.
DEC-2005, Paul Hick (UCSD/CASS)
Modified to deal with presence of -overwrite on cmd line
JUN-2006, Paul Hick (UCSD/CASS), V5.1
Added smei_skyd_size subroutine to control size of
votes arrays.
Added direction cosine angle in long dimension to
skymap file. Note that this changes the layout of the
Fits skymap file.
JUL-2006, Paul Hick (UCSD/CASS), V5.3
Fixed error in some of the comments for the map description
keyword for the polar maps.
Added Fits keyword STIME and ETIME to extension containing the time
STIME in seconds since the first frame used (these were only specified
in the main header). STIME is the time origin for the array.
MAR-2007, Paul Hick (UCSD/CASS; pphick@ucsd.edu), V6.1
Added check for "bad pixel" mask presence for camera 3.
The "closed shutter" calibration pattern for camera 3 is different
depending on whether a "bad pixel" mask is in effect.
MAY-2007, Paul Hick (UCSD/CASS; pphick@ucsd.edu), V6.2
Added GridSphereWeight calls to smooth low resolution maps
where only a few CCD pixels (< 3) contribut a skybin.
[Previous]
[Next]
NAME:
smei_skyd_sort
PURPOSE:
Sorts the node ID of all nodes
CALLING SEQUENCE:
entry smei_skyd_sort(iSilent)
INPUTS:
iSilent controls informational messages
OUTPUTS:
CALLS: ***
ArrI4Copy, ArrI4GetMinMax, BadR4, BadR8, Flt2Str, IndexI4, Int2Str, Say, Str2Str, cInt2Str
datan2d, dcosd, dsind, quaternion_rotate_xyz, smei_axis_cam, smei_skyd_combine
smei_skyd_node2sky, smei_skyd_pixel, smei_skyd_size
CALLED BY:
smei_skyd_fts, smei_skyd_init, smei_skyd_make, smei_skyd_sky
PROCEDURE:
The sorted array are described by a couple of arrays
that are saved internally
node_sort index array to sort nodes
n_nodes(SKYD__NODE_NEMPTY)
number of empty slots in pool
(these are located at the bottom of the node_sort array)
n_nodes(SKYD__NODE_IEMPTY)
counter used when filling up empty slots in smei_skyd_fill
(initialized to zero here)
n_nodes(*) is set zero at the start of a new orbit, forcing the
initialization of n_nodes(SKYD__NODE_NSORT), n_nodes(SKYD__NODE_NEMPTY) and
n_nodes(SKYD__NODE_IEMPTY) to zero.
MODIFICATION HISTORY:
FEB-2006, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
[Previous]
[Next]
NAME:
smei_Time2Split
PURPOSE:
Extract time in SMEI format from string
CALLING SEQUENCE:
subroutine smei_Time2Split(id,cStr,tt)
INPUTS:
id integer indicates method of locating
the time in SMEI format
id=0: time starts after first underscore
id=1: time starts after first underscore
of file name part
id=2: time starts at 1st char of string
cStr character*(*) string containing SMEI time
OUTPUTS:
tt(2) integer time as 2-element standard time
CALLED BY:
smei_base, smei_cal, smei_cal_get, smei_cal_group, smei_cal_init, smei_cal_read
smei_foreign, smei_frm_base, smei_frm_get, smei_frm_getfirst, smei_frm_getnext
smei_frm_path, smei_frm_ped_guess, smei_frm_read, smei_frm_read_get_sdark
smei_orb, smei_orb_cal_name, smei_orb_camera, smei_orb_min_name
smei_orb_min_number, smei_orb_name, smei_orb_number, smei_orb_read
smei_orb_time, smei_orb_version
INCLUDE:
include 'filparts.h'
CALLS: ***
Time2Split, iGetFileSpec, iSetFileSpec
MODIFICATION HISTORY:
FEB-2005, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
[Previous]
[Next]
NAME:
Sort2I2
PURPOSE:
Rearrange two array so that the first one is put into ascending
numerical order
CATEGORY:
Math: sorting
CALLING SEQUENCE:
subroutine Sort2I2(N1,N2,M1,M2,RA,RB)
INPUTS:
N1,N2 integer logical dimensions of array RA
M1,M2 integer physical dimensions of array RA
(only the logical part of the array is sorted
RA(M1:M2) integer*2 array to be sorted
RB(M1:M2) integer*2 array to be sorted
OUTPUTS:
RA,RB sorted array
SIDE EFFECTS:
The part of the arrays RA,RB outside the logical range (i.e. indices
[M1,N1-1] and [N2+1,M2] remains untouched
RESTRICTIONS:
The logical range [N1,N2] must be a subset of physical range [M1,M2]
SEE ALSO:
IndexI2, Rank, Sort2I4, Sort2R4, Sort2R8, SortI2
PROCEDURE:
Modification of the heapsort subroutine in Press et al., "Numerical
Recipes", Cambridge UP (1989), par. 8.2, p. 231
MODIFICATION HISTORY:
1990, Paul Hick (UCSD)
[Previous]
[Next]
NAME:
Sort2I4
PURPOSE:
Rearrange two array so that the first one is put into ascending
numerical order
CATEGORY:
Math: sorting
CALLING SEQUENCE:
subroutine Sort2I4(N1,N2,M1,M2,RA,RB)
INPUTS:
N1,N2 integer logical dimensions of array RA
M1,M2 integer physical dimensions of array RA
(only the logical part of the array is sorted
RA(M1:M2) integer array to be sorted
RB(M1:M2) integer array to be sorted
OUTPUTS:
RA,RB sorted array
SIDE EFFECTS:
The part of the arrays RA,RB outside the logical range (i.e. indices
[M1,N1-1] and [N2+1,M2] remains untouched
RESTRICTIONS:
The logical range [N1,N2] must be a subset of physical range [M1,M2]
SEE ALSO:
IndexI4, Rank, Sort2I2, Sort2R4, Sort2R8, SortI4
PROCEDURE:
Modification of the heapsort subroutine in Press et al., "Numerical
Recipes", Cambridge UP (1989), par. 8.2, p. 231
MODIFICATION HISTORY:
1990, Paul Hick (UCSD)
[Previous]
[Next]
NAME:
Sort2R4
PURPOSE:
Rearrange two array so that the first one is put into ascending
numerical order
CATEGORY:
Math: sorting
CALLING SEQUENCE:
subroutine Sort2R4(N1,N2,M1,M2,RA,RB)
INPUTS:
N1,N2 integer logical dimensions of array RA
M1,M2 integer physical dimensions of array RA
(only the logical part of the array is sorted
RA(M1:M2) real array to be sorted
RB(M1:M2) real array to be sorted
OUTPUTS:
RA,RB sorted array
CALLED BY:
nrInterpol
SIDE EFFECTS:
The part of the arrays RA,RB outside the logical range (i.e. indices
[M1,N1-1] and [N2+1,M2] remains untouched
RESTRICTIONS:
The logical range [N1,N2] must be a subset of physical range [M1,M2]
SEE ALSO:
IndexR4, Rank, Sort2I2, Sort2I4, Sort2R8, SortR4
PROCEDURE:
Modification of the heapsort subroutine in Press et al., "Numerical
Recipes", Cambridge UP (1989), par. 8.2, p. 231
MODIFICATION HISTORY:
1990, Paul Hick (UCSD)
[Previous]
[Next]
NAME:
Sort2R8
PURPOSE:
Rearrange two array so that the first one is put into ascending
numerical order
CATEGORY:
Math: sorting
CALLING SEQUENCE:
subroutine Sort2R8(N1,N2,M1,M2,RA,RB)
INPUTS:
N1,N2 integer logical dimensions of array RA
M1,M2 integer physical dimensions of array RA
(only the logical part of the array is sorted
RA(M1:M2) double precision array to be sorted
RB(M1:M2) double precision array to be sorted
OUTPUTS:
RA,RB sorted arrays
INCLUDE:
include 'sort_inc.h'
SIDE EFFECTS:
The part of the arrays RA,RB outside the logical range (i.e. indices
[M1,N1-1] and [N2+1,M2] remains untouched
RESTRICTIONS:
The logical range [N1,N2] must be a subset of physical range [M1,M2]
SEE ALSO:
IndexR8, Rank, Sort2I2, Sort2I4, Sort2R4, SortR8
PROCEDURE:
Modification of the heapsort subroutine in Press et al., "Numerical
Recipes", Cambridge UP (1989), par. 8.2, p. 231
MODIFICATION HISTORY:
1990, Paul Hick (UCSD)
[Previous]
[Next]
NAME:
SortI2
PURPOSE:
Rearrange array into ascending numerical order
CATEGORY:
Math: sorting
CALLING SEQUENCE:
subroutine SortI2(N1,N2,M1,M2,RA)
INPUTS:
N1,N2 integer logical dimensions of array RA
M1,M2 integer physical dimensions of array RA
RA(M1:M2) integer*2 array to be sorted
OUTPUTS:
RA integer*2 sorted array
RESTRICTIONS:
The logical range [N1,N2] must be a subset of physical range [M1,M2]
I.e. N1 >= M1 and N2 <= M2.
SEE ALSO:
IndexI2, Rank, Sort2I2, SortI4, SortR4, SortR8
MODIFICATION HISTORY:
1990, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
[Previous]
[Next]
NAME:
SortI4
PURPOSE:
Rearrange array into ascending numerical order
CATEGORY:
Math: sorting
CALLING SEQUENCE:
subroutine SortI4(N1,N2,M1,M2,RA)
INPUTS:
N1,N2 integer logical dimensions of array RA
M1,M2 integer physical dimensions of array RA
RA(M1:M2) integer*4 array to be sorted
OUTPUTS:
RA integer*4 sorted array
CALLED BY:
Pandora
RESTRICTIONS:
The logical range [N1,N2] must be a subset of physical range [M1,M2]
I.e. N1 >= M1 and N2 <= M2.
SEE ALSO:
IndexI4, Rank, Sort2I4, SortI2, SortR4, SortR8
MODIFICATION HISTORY:
1990, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
[Previous]
[Next]
NAME:
SortIPS
PURPOSE:
Sort the original Nagoya and Ooty IPS files into chronological order
CALLING SEQUENCE:
program SortIPS
INPUTS:
Name of unsorted input file (by user prompt)
OUTPUTS:
The sorted data are written to a file NAGOYA.%% and Ooty,%%,
where %% stands for the year, e.g. 90 for 1990 data.
INCLUDE:
include 'openfile.h'
include 'filparts.h'
CALLS: ***
AskWhat, DATE_DOY, IndexR4, Int2Str, Say, Str2Str, bOpenFile, iFreeLun, iGetFileSpec
itrim
PROCEDURE:
> All records are read into a big string array STRINGS.
A TIMES array (doy of year) is extracted from the STRINGS array.
This TIMES array is sorted to obtain an index array. The year,month
day and UT are used to calculate TIMES. The index array is then used
to write the STRINGS array into the new file in sorted order.
>
MODIFICATION HISTORY:
JUN-1994, Paul Hick (UCSD)
MAR-2011, John Clover (UCSD/CASS)
Increased nREC to 20000
[Previous]
[Next]
NAME:
SortR4
PURPOSE:
Rearrange array into ascending numerical order
CATEGORY:
Math: sorting
CALLING SEQUENCE:
subroutine SortR4(N1,N2,M1,M2,RA)
INPUTS:
N1,N2 integer logical dimensions of array RA
M1,M2 integer physical dimensions of array RA
RA(M1:M2) real*4 array to be sorted
OUTPUTS:
RA real*4 sorted array
CALLED BY:
ArrR4Median
RESTRICTIONS:
The logical range [N1,N2] must be a subset of physical range [M1,M2]
I.e. N1 >= M1 and N2 <= M2.
SEE ALSO:
IndexR4, Rank, Sort2R4, SortI2, SortI4, SortR8
MODIFICATION HISTORY:
1990, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
[Previous]
[Next]
NAME:
SortR8
PURPOSE:
Rearrange array into ascending numerical order
CATEGORY:
Math: sorting
CALLING SEQUENCE:
subroutine SortR8(N1,N2,M1,M2,RA)
INPUTS:
N1,N2 integer logical dimensions of array RA
M1,M2 integer physical dimensions of array RA
(only the logical part of the array is sorted
RA(M1:M2) double precision array to be sorted
OUTPUTS:
RA double precision sorted array
SEE ALSO:
IndexR8, Rank, Sort2R8, SortI2, SortI4, SortR4
SIDE EFFECTS:
The part of the array RA outside the logical range (i.e. indices
[M1,N1-1] and [N2+1,M2] remains untouched
RESTRICTIONS:
The logical range [N1,N2] must be a subset of physical range [M1,M2]
I.e. N1 >= M1 and N2 <= M2.
PROCEDURE:
Modification of the heapsort subroutine in Press et al., "Numerical
Recipes", Cambridge UP (1989), par. 8.2, p. 231
MODIFICATION HISTORY:
1990, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
[Previous]
[Next]
NAME:
SphereWeight
PURPOSE:
Assign a weight to a point on the surface of the sphere, based on the
angular distance of the point relative to a reference point ('origin')
CATEGORY:
Auxilliary
CALLING SEQUENCE:
function SphereWeight(DXL,YL0,YL1,DL,NTYPE,CUTOFF,WHALF)
INPUTS:
DXL real difference in longitude between data point and origin
(degrees; longitude [0,360])
YL0 real latitude of origin (degrees; latitude [-90,90])
YL1 real latitude of data point (degrees)
DL real half-width of weight function (degrees)
NTYPE integer defines type of weight function
= 1 block function (weight 1 inside, 0 outside DL)
= 2 (1/x)*exp(-x**2); x = Ang.dist/DL
= 3 exp(-x**2); x = Ang.dist/DL
(other functions can be added if necessary)
CUTOFF real if angular distance > CUTOFF*DL, the weight is set to
zero (may be necessary to prevent floating underflow)
OUTPUTS:
SphereWeight real weighting factor
WHALF real weigthing factor at distance DL
CALLS: ***
Say, acosd, cosd, sind
CALLED BY:
MapGrid
INCLUDE:
include 'math.h'
MODIFICATION HISTORY:
> The weight function is defined on the surface of a sphere with unit
radius, i.e. is a function of two variables THETA,PHI in any spherical
coordinate system defined on the sphere.
> The weight function will generally be a rapidly decreasing function of
the angular distance between the origin and a data point
[Previous]
[Next]
NAME:
SplineGridX
PURPOSE:
Interpolation of 2D arrays in horizontal direction.
CATEGORY:
Interpolation using natural spline
CALLING SEQUENCE:
subroutine SplineGridX(iFlag,XN1,XN2,XM1,XM2,NX,NY,ZN,MX,ZM)
INPUTS:
iFlag integer 1st bit set: flag bad point in output ZM if
nearest grid point in input ZN is bad.
2nd bit set: if the range [XM1,XM2] extends
outside [XN1,XN2] then x-coordinates outside
[XN1,XN2] are mapped back inside
by a mod (XN2-XN1) operation.
XN1 real x-coordinate of 1st column of input ZN
XN2 real x-coordinate of last column of input ZN
XM1 real x-coordinate of 1st column of output ZM
XM2 real x-coordinate of last column of output ZM
NX integer horizontal dimensions of ZN
NY integer vertical dimensions of ZN
ZN(NX,NY) real fnc-values
MX integer new horizontal dimension
OUTPUTS:
ZM(MX,NY) real interpolated fnc-values
CALLS: ***
ArrR4Step, Say, SplineX
CALLED BY:
MapReadSingle, MapReadTimes, nrSqueezeX
RESTRICTIONS:
The in- and output user-coordinate ranges must be non-zero
PROCEDURE:
> 1st bit of iFlag is set: for each grid point of the output grid the
nearest grid point of the output grid is determined. If this nearest
point was flagged (contained value BadR4()) then the value of the
output grid is also flagged.
!! `Nearest' means the nearest grid point in the
horizontal direction only (along a single row);
> For each row in ZN a spline is calculated, using all valid fnc-values
in that row. The ordinate for the spline is assumed to run from
XN1 to XN2. The spline is then used to interpolate fnc-values in
evenly spaced ordinate values between XM1 and XM2.
> If the row dimension is not changed, SplineGridX and has the effect of
filling in the invalid function values (if 1st bit of iFlag is set)
MODIFICATION HISTORY:
JUL-1993, Paul Hick (UCSD/CASS)
APR-1994, Paul Hick (UCSD/CASS)
added argument bFlag to control flagging of function values in the output array
MAY-2002, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
added arguments MX and ZM to allow changes in horizontal dimension
Note that the old functionality is retained by setting MX=NX, ZM=ZN
Changed logical argument bFlag to integer argument iFlag. The original bFlag
functionality is now controlled by the first bit in iFlag. The second bit
is now used to contol the mod( XN2-XN1) ) behavior.
[Previous]
[Next]
NAME:
SplineGridY
PURPOSE:
Interpolation of 2D arrays in vertical direction.
CATEGORY:
Interpolation using natural spline
CALLING SEQUENCE:
subroutine SplineGridY(iFlag,YN1,YN2,YM1,YM2,NX,NY,ZN,MY,ZM)
INPUTS:
iFlag integer 1st bit set: flag bad point in output ZM if
nearest grid point in ZN is bad.
2nd bit set: if the range [YM1,YM2] extends
outside [YN1,YN2] then y-coordinates outside
[YN1,YN2] are mapped back inside
by a mod (YN2-YN1) operation.
YN1 real y-coordinate of 1st row of input ZN
YN2 real y-coordinate of last row of input ZN
YM1 real y-coordinate of 1st row of output ZM
YM2 real y-coordinate of last row of output ZM
NX integer horizontal dimension of ZN
NY integer vertical dimensions of ZN
ZN(NX,NY) real fnc-values
MY integer new vertical dimension
OUTPUTS:
ZM(NX,MY) real interpolated fnc-values
CALLS: ***
ArrR4Step, Say, SplineY
CALLED BY:
MapReadSingle, MapReadTimes, nrSqueezeY
RESTRICTIONS:
The in- and output user-coordinate ranges must be non-zero
PROCEDURE:
> 1st bit of iFlag is set: for each grid point of the output grid the
nearest grid point of the output grid is determined. If this nearest
point was flagged (contained value BadR4()) then the value of the
output grid is also flagged.
!! `Nearest' means the nearest grid point in the
in the vertical direction only (along a single column).
> For each column in ZN a spline is calculated, using all valid fnc-values
in that column. The ordinate for the spline is assumed to run from
YN1 to YN2. The spline is then used to interpolate fnc-values in
evenly spaced ordinate values between YM1 and YM2.
> If the column dimension is not changed, SplineGridY has the effect of
filling in the invalid function values (if 1st bit of iFlag is set)
MODIFICATION HISTORY:
JUL-1993, Paul Hick (UCSD/CASS)
APR-1994, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
added argument bFlag to control flagging of function values in the output array
MAY-2002, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
added arguments MY and ZM to allow changes in horizontal dimension
Note that the old functionality is retained by setting MY=NY, ZM=ZN
Changed logical argument bFlag to integer argument iFlag. The original bFlag
functionality is now controlled by the first bit in iFlag. The second bit
is now used to contol the mod( YN2-YN1 ) behavior.
[Previous]
[Next]
NAME:
SplineX
PURPOSE:
Interpolation of 2D arrays in first (horizontal) dimension.
CATEGORY:
Interpolation using natural spline
CALLING SEQUENCE:
subroutine SplineX(iFlag,NX,XN,MX,XM,NY,ZN,ZM)
INPUTS:
iFlag integer 1st bit set: flag bad point in output ZZ if
nearest grid point in Z is bad.
2nd bit set: if the range of XM extends
outside the range of XN then x-coordinates outside
the range of XN are mapped back inside
by a mod ( max(XN)-min(XN)) operation.
NX integer first (horizontal) dimension of input ZN
XN(NX) real horizontal coordinates for input ZN
MX integer first (horizontal) dimension of output ZM
XM(MX) real horizontal coordinates for output ZM
ZN(NX,NY) real fnc-values
OUTPUTS:
ZM(MX,NY) real interpolated fnc-values
CALLS: ***
ArrR4GetMinMax, BadR4, IndexR4, Say, nrSplInt, nrSpline
CALLED BY:
SplineGridX
SEE ALSO:
SplineGridX, SplineGridY, SplineY
RESTRICTIONS:
The in- and output horizontal coordinate ranges must be non-zero
PROCEDURE:
> 1st bit of iFlag is set: for each grid point of the output grid the
nearest grid point of the output grid is determined. If this nearest
point was flagged (contained value BadR4()) then the value of the
output grid is also flagged.
!! `Nearest' means the nearest grid point in the
horizontal direction only (along a single row);
> For each row in Z a spline is calculated, using all valid fnc-values
in that row. XN provides the ordinates for the spline
> If the row dimension is not changed (NX=MX), SplineX and has the effect of
filling in the invalid function values (if 1st bit of iFlag is set).
In this case the same array can be used for both ZN and ZM.
MODIFICATION HISTORY:
JUL-1993, Paul Hick (UCSD/CASS)
APR-1994, Paul Hick (UCSD/CASS)
added argument bFlag to control flagging of function values in the output array
MAY-2002, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
Generalized version of old SplineGridX. Instead of working with evenly spaced
ordinate values, now arbitrary ordinate values for in- and output arrays
are allowed.
Changed logical argument bFlag to integer argument iFlag. The original bFlag
functionality is now controlled by the first bit in iFlag. The second bit
is now used to contol the mod(Xmax-Xmin) behavior.
[Previous]
[Next]
NAME:
SplineY
PURPOSE:
Interpolation of 2D arrays in second (vertical) dimension.
CATEGORY:
Interpolation using natural spline
CALLING SEQUENCE:
subroutine SplineY(iFlag,NY,YN,MY,YM,NX,ZN,ZM)
INPUTS:
iFlag integer 1st bit set: flag bad point in output ZN if
nearest grid point in ZM is bad.
2nd bit set: if the range of YM extends
outside the range of YN then y-coordinates outside
the range of YN are mapped back inside
by a mod ( max(YN)-min(YN)) operation.
NY integer second (vertical) dimension of input ZN
YN(NY) real vertical coordinates for input ZN
MY integer second (vertical) dimension of output ZM
YM(MY) real vertical coordinates for output ZM
ZN(NX,NY) real fnc-values
OUTPUTS:
ZM(NX,MY) real interpolated fnc-values
CALLS: ***
ArrR4GetMinMax, BadR4, IndexR4, Say, nrSplInt, nrSpline
CALLED BY:
MapReadTimes, SplineGridY
SEE ALSO:
SplineGridX, SplineGridY, SplineX
RESTRICTIONS:
The in- and output vertical coordinate ranges must be non-zero
PROCEDURE:
> 1st bit of iFlag is set: for each grid point of the output grid the
nearest grid point of the output grid is determined. If this nearest
point was flagged (contained value BadR4()) then the value of the
output grid is also flagged.
!! `Nearest' means the nearest grid point in the
vertical direction only (along a single column);
> For each column in ZN a spline is calculated, using all valid fnc-values
in that column. YN provides the ordinates for the spline
> If the column dimension is not changed (NY=MY), SplineY and has the effect of
filling in the invalid function values (if 1st bit of iFlag is set)
In this case the same array can be used for both ZN and ZM.
MODIFICATION HISTORY:
JUL-1993, Paul Hick (UCSD/CASS)
APR-1994, Paul Hick (UCSD/CASS)
added argument bFlag to control flagging of function values in the output array
MAY-2002, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
Generalized version of old SplineGridY. Instead of working with evenly spaced
ordinate values, now arbitrary ordinate values for in- and output arrays
are allowed.
Changed logical argument bFlag to integer argument iFlag. The original bFlag
functionality is now controlled by the first bit in iFlag. The second bit
is now used to contol the mod( max(YN)-min(YN) ) behavior.
[Previous]
[Next]
NAME:
sprint
PURPOSE:
Copy a specified file to another file, with selected format,
ready to be printed
CATEGORY:
I/O
CALLING SEQUENCE:
program SPRINT
run $exe:sprint (vms)
$ $exe:sprint filename (vms)
$exe/sprint (linux)
INPUTS:
filename Name of text file to be processed (optional)
If no file name is specified, user is prompted
The program attempts to read the following global DCL symbols (only
the page length indicator is mandatory):
LIB__LS_PAGEL # lines per page, minus 3 (for the header)
LIB__LS_PRNT the VMS-DCL or Linux-bash command which submits the file
for printing
LIB__LS_START initialize sequence for printer (1st line of print file)
LIB__LS_STOP soft reset sequence for printer (last line)
LIB__LS_FF if set to "YES" an explicit formfeed is written at
the end of each page (if the page length set in
LIB__LS_PAGEL exactly matches the intrinsic page length
of the printer this may not be necessary).
OUTPUTS:
?.las Scratch file to be send to printed and deleted
INCLUDE:
include 'dirspec.h'
include 'filparts.h'
include 'openfile.h'
CALLS: ***
ForeignArg, LocFirst, OSExitCmd, Say, Str2Str, bOpenFile, cTime2System, iFreeLun
iGetFileSpec, iGetLogical [1], iGetLogical [2], iGetSymbol [1], iGetSymbol [2]
iHideLogical, iOSDeleteFile, iOSRenameFile, iOSSpawnCmd, iSearch, iSetFileSpec
iUniqueName, itrim, uppercase
PROCEDURE:
> The input text file is processed record by record and are written to
an output scratch file. The scratch file is printed and deleted.
> The output file '?.las' is created in SYS$SCRATCH
> Wild cards are permitted in the input file name
> If the second calling sequence is used ($SPRINT), then a comma separated
list of arguments is permitted. Each argument can contain a wild card.
> By default the output file includes line numbers.
Command line switches (preceded by "/"):
> /NOLINENUMBERS: the line numbers are suppressed.
> /MARGIN (only used in combination with /NOLINENUMBERS):
add a margin of one tab (8 characters) on the left.
> /COUNTONLY: only a page count is given. Nothing is actually printed.
> /NOCRLFFF: an output file with a higher version number
(same directory and name as input file) is created with trailing CR,LF
and/or FF remove. I.e. no header is added, and no printer initialize
and reset string.
> /FORTRAN: the scratch file send to the printer is
identical to the input file except for an additional header (consisting
of the ALL initialize string, the system time and the file name) and
an additional trailer (the RSP reset string). This option is useful
for printing files with FORTRAN carriagecontrol.
> /CRLF: CR and LF's are explicitly processed. By default they are
stripped out and ignored.
> /LANDSCAPE: printing is in landscape mode
> /DELETE: the original input file is deleted after processing
(NOTE: whether the scratch file is deleted depends on the print command)
> /HELP: display few lines of help
> The landscape option uses the global symbols LIB__LS_LAND and
LIB__LS_LANDL instead of LIB__LS_START and LIB__LS_PAGEL, respectively.
These symbols are available for the HP Laserjet printer, but is
currently not of much use, since it only prints a maximum of 132
characters per line (only a few characters more than in portrait mode)
> On Linux the script $com/sprint_setup adds the required symbols to
the file ~/LOGFIL.TXT.
MODIFICATION HISTORY:
Original HC.FOR by George L. Huszar May, 1991
OCT-1991, Paul Hick (UCSD), modified to accept external input
MAR-1992, Paul Hick (UCSD), added loop for wild-card specification
FEB-1993, Paul Hick (UCSD),
- option to suppress line numbers
- option to get page count without actually printing
- added removal of trailing CR,LF and FF
- option to retain file with CR,LF and FF removed
- option to print files with FORTRAN carriagecontrol
MAR-1995, Paul Hick (UCSD), added option to delete the original input
file after processing
MAR-1995, Paul Hick (UCSD), introduced command line switches to
differentiate between various options (used to be numericals
appended to the list of file names)
AUG-2000, Kevin Nguyen, Paul Hick (UCSD)
Adapted for Linux. The main change was the addition of an
explicit carriage return after all text output to the scratch
file before sending it to the printer. The current print command
is lpr -Php -r. All required LIB__* symbols are set up by
the script $com/sprint_setup.
[Previous]
[Next]
NAME:
step_fnc
PROCEDURE:
Never tested
[Previous]
[Next]
NAME:
StereoAOrbit
PURPOSE:
Calculate Stereo orbit (position and velocity vectors)
CATEGORY:
/gen/for/lib/ephem
CALLING SEQUENCE:
subroutine StereoAOrbit(iYr,Doy,RR,VV)
INPUTS:
iYr integer year
Doy real day of year
OUTPUTS:
RR(3) real position vector: ecliptic longitude and
latitude (deg), radial distance (AU)
VV(5) real velocity vector: ecliptic longitude and
latitude (deg), magnitude, radial and
tangential velocity (AU/day)
(will be zero if the Ulysses orbital
data base is used; see PROCEDURE).
CALLS: ***
Julian, KeplerOrbit, Say
CALLED BY:
ExtractPosition, ExtractPositionn8
PROCEDURE:
Times have to be later than 2007/01/01 00 UT
MODIFICATION HISTORY:
JUL-1998, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
[Previous]
[Next]
NAME:
StereoBOrbit
PURPOSE:
Calculate Stereo B (position and velocity vectors)
CATEGORY:
/gen/for/lib/ephem
CALLING SEQUENCE:
subroutine StereoBOrbit(iYr,Doy,RR,VV)
INPUTS:
iYr integer year
Doy real day of year
OUTPUTS:
RR(3) real position vector: ecliptic longitude and
latitude (deg), radial distance (AU)
VV(5) real velocity vector: ecliptic longitude and
latitude (deg), magnitude, radial and
tangential velocity (AU/day)
(will be zero if the Ulysses orbital
data base is used; see PROCEDURE).
CALLS: ***
Julian, KeplerOrbit, Say
CALLED BY:
ExtractPosition, ExtractPositionn8
PROCEDURE:
Times have to be later than 2007/01/01 00 UT
MODIFICATION HISTORY:
JUL-1998, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
[Previous]
[Next]
NAME:
StereoOrbit
PURPOSE:
Calculate the Stereo A and B orbit (position locations)
CATEGORY:
Celestial mechanics
CALLING SEQUENCE:
subroutine StereoOrbit(nS,iYr,Doy,RR)
INPUTS:
nS 1 - Stereo A
2 - Stereo B
iYr integer year
Doy real day of year
OUTPUTS:
RR(3) real position vector: ecliptic longitude and
latitude (deg), radial distance (AU).
CALLS: ***
Julian, KeplerOrbit
INCLUDE:
PROCEDURE:
> If the data base with Ulysses orbital coordinates exists (file
$dat:UlyssesPos.txt) the position vector is obtained by
linear interpolation on the data base.
> If the data base does not exist, approximate orbital parameters
are used. These parameters were determined by least-square fitting
Ulysses orbital data from the years 1993 to 1996 (first polar passage).
MODIFICATION HISTORY:
JUN-1997, Paul Hick (UCSD/CASS; pphick@ucsd.edu), JUL-2008 (UCSD/CASS; bjackson@ucsd.edu)
[Previous]
[Next]
NAME:
stop_here
PURPOSE:
Stop the program with a message.
This is a workaround for 'stop' directly used inside an OpenMP loop.
CALLING SEQUENCE:
call stop_here(msg)
CALLED BY:
MkGModeltdn, MkVModeltd
[Previous]
[Next]
NAME:
StopWatch
PURPOSE:
Display time difference between start and stop time
(start time can be set internally; stop time can be system time)
CALLING SEQUENCE:
subroutine StopWatch(cStartIn,cStopIn)
INPUTS: (read-only)
cStart character*(*) start time string; absolute time
cStop character*(*) (optional) stop time string
special value cStop = ' ' or cStop = '_'
OUTPUTS:
Displayed on screen
CALLS: ***
StopWatchSub, cTime2System
CALLED BY:
ipsg2, ipsg2s, ipsg2t, timer
RESTRICTIONS:
No check is made whether START is in the proper absolute time format.
If not, all bets are off.
PROCEDURE:
> If START .eq. ' ':
- the first call to StopWatch will set and save the system time
- the second call to StopWatch will display the elapsed time between
the cStart time set in the previous call and the specified cStop time.
> If cStart .ne. ' ':
- the start time must be in absolute time format YYY/MN/DD hh:mm:ss.ss,
> If cStop = ' ' or cStop = '_' the current system time is used as stop
time. Otherwise it must be an absolute time
MODIFICATION HISTORY:
JAN-1993, Paul Hick (UCSD/CASS)
Original written in Lindau.
NOV-2004, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
Rewritten using Time2* routines.
[Previous]
[Next]
NAME:
StopWatchSub
PURPOSE:
Clock the time elapsed since given start time
CALLING SEQUENCE:
subroutine StopWatchSub(cStart,cStop,cLapsed)
INPUTS:
cStart character*(*) read-only start time string; absolute time
cStop character*(*) (optional) stop time string
special input: cStop = ' ' and cStop = '_'
OUTPUTS:
cStop character*(*) current time string
LAPSED character*(*) time difference string
format DDD HH:MM:SS.SS
CALLS: ***
Time2Delta, Time2Split, Time2Str, Time2System
CALLED BY:
StopWatch
RESTRICTIONS:
There is no check whether the input times are in the proper absolute
time format. If not, all bets are off.
PROCEDURE:
> The input and (optional) stop time must be specified as absolute times,
in the format specified in argument cFmt.
> if the input string cStop = ' ' or cStop = '_' then the stop time is
obtained using Time2System
> if cStop = ' ' the stop time is not returned, i.e. cStop is used read-only
> if cStop = '_' the stop time is returned
> the time difference is returned in the form DDD HH:MM:SS.SS.
If the number of days DDD=0 the DDD part is filled with blanks.
MODIFICATION HISTORY:
JAN-1993, Paul Hick (UCSD/CASS)
Original written in Lindau.
NOV-2004, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
Rewritten using Time2* routines.
[Previous]
[Next]
NAME:
Str2Dbl
PURPOSE:
Extract numbers from string and put them in floating point array
CALLING SEQUENCE:
entry Str2Dbl(cStr,nVec,dVec)
INPUTS:
cStr string (e.g. 89/1/12)
nVec integer max # elements read into rVec
OUTPUTS:
nVec integer # elements of rVec filled
If more than nVec numbers were located in the input
string, then nVec is set to the NEGATIVE of the
input value of nVec.
rVec real floating point array with identified numbers
CALLS: ***
Int2Str, Int2StrSet, Say, Str2Flt_CheckNext, Str2Flt_FmtCrumbs, Str2Flt_FmtNumbers
Str2Str, itrim, uppercase
CALLED BY:
AskLimit, BList_NSO_NOAA, BList_WSO_NOAA, ForeignR8ArgN, bStr2Dbl
PROCEDURE:
Double precision version of Flt2Str
[Previous]
[Next]
NAME:
Str2Flt
PURPOSE:
Extract numbers from string and put them in floating point array
CALLING SEQUENCE:
subroutine Str2Flt(cStr,nVec,rVec)
INPUTS:
cStr string (e.g. 89/1/12)
nVec integer max # elements read into rVec
OUTPUTS:
nVec integer # elements of rVec filled
If more than nVec numbers were located in the input
string, then nVec is set to the NEGATIVE of the
input value of nVec.
rVec real floating point array with identified numbers
CALLS: ***
Int2Str, Int2StrSet, Say, Str2Flt_CheckNext, Str2Flt_FmtCrumbs, Str2Flt_FmtNumbers
Str2Str, itrim, uppercase
CALLED BY:
AskWhatPrmpt, BList_NSO_NOAA, BList_WSO, BList_WSO_NOAA, BRead_WSO
DailyIPS_UCSD [1], DailyIPS_UCSD [2], ExpandSW, FileSelection, ForeignR4ArgN
Pandora, ReadGHD, ReadVIPS, ReadVIPSLOSCheck, ReadVIPSLOSCheckn, ReadVIPSn, SD_SCAN
T3D_marker, T3D_marker_num, WR2DARR, bStr2Flt, iFltArr, iFourDigitYear [1]
iFourDigitYear [2], smei_frm_path
SEE ALSO:
Str2Flt_Crumbs, Str2Flt_Exp, Str2Flt_FforI, Str2Flt_Format, Str2Flt_Int
Str2Flt_Mask, Str2Flt_XforA, bStr2Flt
INCLUDE:
include 'str2str_inc.h'
PROCEDURE:
> Str2Flt is the main program unit. It checks each character in cStr against
a list of valid characters. Processing characters sequentially going
from first to last, the largest possible substrings representing valid
numbers are extracted.
> If the number of valid numbers in cStr exceeds the requested input
value of nVec, then (output nVec) = -(input nVec). I.e. a negative
return value of nVec indicates that not all numbers have been read
from cStr into the output array rVec.
> By default Str2Flt does not search for exponents (i.e. E and D are
not considered a valid part of a number). If Str2Flt_Exp is called prior
to Str2Flt, then integer exponents will be recognized. The setting
specified by Str2Flt_Exp is only valid for one call to Str2Flt
> Str2Flt builds a format string describing cStr. After the call to
Str2Flt the format string can be extracted using Str2Flt_Format.
> All substrings in cStr that can not be interpreted as part of a
valid number are stored in a string array. The array can be extracted
using Str2Flt_Crumbs. The maximum number of substrings extracted is
currently 20; the max length of each substring also is 20.
Str2Flt_Crumbs also returns the total number of character in cStr
that have not been interpreted as part of a number.
> bStr2Flt is a special case of a Str2Flt call. It will return .TRUE.
if cStr contains exactly nVec numbers with no residual characters
that are not part of any number. (It's used by the ASK routines to
verify whether a valid number has been entered).
MODIFICATION HISTORY:
Written Jan 1989 by DMZ (ARC)
Converted to V2 Dec 1990 by DMZ (ARC)
OCT-1990, Paul Hick (ARC), rewritten and expanded to accept exponentials
DEC-1992, Paul Hick (UCSD/CASS), converted from IDL
SEP-2002, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
Fairly substantial rewrite to remove remaining statement labels.
[Previous]
[Next]
NAME:
Str2Flt_CheckNext
PURPOSE:
(Internal use by Str2Flt only)
Checks whether character following char I in string Str is present in Valid.
CALLING SEQUENCE:
logical function Str2Flt_CheckNext(nLen,cStr,nMask,cMask,I,CH,cValid,iFirst)
INPUTS:
nLen integer effective length of cStr
cStr character*(*) string
nMask
cMask
I integer
CH character
cValid character*(*)
iFirst integer
OUTPUTS:
Str2Flt_CheckNext
logical
I integer
CH character
iFirst integer
CALLED BY:
Str2Dbl, Str2Flt, Str2Flt_Exp, Str2Flt_FforI, Str2Flt_Int, Str2Flt_Mask
Str2Flt_XforA, Str2Int
PROCEDURE:
Called when CH = cStr(I:I) is a '+', '-' or dot. To be part of a valid
number the char following I must be a dot or digit (if CH = '+' or '-') or
it must be a digit (if CH = '.').
MODIFICATION HISTORY:
SEP-2002, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
[Previous]
[Next]
NAME:
Str2Flt_Crumbs
PURPOSE:
Extract parts of cStr that did not fit into any numbers
CALLING SEQUENCE:
entry Str2Flt_Crumbs(lCrumbsOut,nCrumbsOut,cCrumbsOut)
INPUTS:
nCrumbs integer max # crumbs to be retrieved
OUTPUTS:
nCrumbs integer # crumbs in cStr
cCrumbs character(20)*20values of all crumbs in cStr
cCrumbs integer total length of all crumbs
CALLS: ***
Int2Str, Str2Str, itrim
CALLED BY:
ReadGHD, bStr2Dbl, bStr2Flt
PROCEDURE:
Entry point in subroutine Str2Flt_FmtNumbers
All substrings in cStr that can not be interpreted as part of a
valid number are stored in a string array.
This subroutine extracts this array. See Str2Flt
MODIFICATION HISTORY:
DEC-1992, Paul Hick (UCSD), converted from IDL
[Previous]
[Next]
NAME:
Str2Flt_Exp
PURPOSE:
Set the value of logical bExp for next call to Str2Flt (def: .FALSE.)
CALLING SEQUENCE:
entry Str2Flt_Exp(bExpIn)
INPUTS:
bExpIn logical .FALSE. : ignore 'E' and 'D'
.TRUE. : exponentials of type 'D' and 'E' are interpreted
CALLS: ***
Int2Str, Int2StrSet, Say, Str2Flt_CheckNext, Str2Flt_FmtCrumbs, Str2Flt_FmtNumbers
Str2Str, itrim, uppercase
CALLED BY:
DailyIPS_UCSD [1], DailyIPS_UCSD [2], ExpandSW, Pandora, bStr2Dbl, bStr2Flt, iFltArr
RESTRICTIONS:
The setting specified by Str2Flt_Exp is only valid for one call to Str2Flt
PROCEDURE:
Entry point in subroutne Str2Flt
By default Str2Flt does not search for exponents (i.e. E and D are
not considered a valid part of a number). If Str2Flt_Exp is called prior
to Str2Flt, then integer exponents will be recognized.
MODIFICATION HISTORY:
DEC-1992, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
[Previous]
[Next]
NAME:
Str2Flt_FforI
PURPOSE:
Determines how integers in the next Str2Flt call are
represented in the format cFmt string: as In or Fn.0
CALLING SEQUENCE:
entry Str2Flt_FforI(bFforIIn)
INPUTS:
bFforIIn logical default: .FALSE.
CALLS: ***
Int2Str, Int2StrSet, Say, Str2Flt_CheckNext, Str2Flt_FmtCrumbs, Str2Flt_FmtNumbers
Str2Str, itrim, uppercase
RESTRICTIONS:
Valid for one call to Str2Flt only.
PROCEDURE:
Entry point in subroutine Str2Flt
If bFforI=.TRUE. then integers are represented as Fn.0
in the cFmt string. The default is In.
MODIFICATION HISTORY:
DEC-1992, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
[Previous]
[Next]
NAME:
Str2Flt_FmtCrumbs
PURPOSE:
(Internal use by Str2Flt only)
Adds component to crumbs array
CALLING SEQUENCE:
entry Str2Flt_FmtCrumbs(Init,cStr,iFirst,iLast,bXforA)
INPUTS:
Init integer 1: initialize new crumb collection
0: add to collection
cStr character string
iFirst integer first char of current number
iLast integer last char of previous number
bXforA logical add X to format instead of A
array of crumbs
OUTPUTS:
CALLS: ***
Int2Str, Str2Str, itrim
CALLED BY:
Str2Dbl, Str2Flt, Str2Flt_Exp, Str2Flt_FforI, Str2Flt_Int, Str2Flt_Mask
Str2Flt_XforA, Str2Int
SEE ALSO:
Str2Flt
PROCEDURE:
Entry point in subroutine Str2Flt_FmtNumbers
MODIFICATION HISTORY:
SEP-2002, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
[Previous]
[Next]
NAME:
Str2Flt_FmtNumbers
PURPOSE:
(Internal use by Str2Flt only)
Adds component to format string
CALLING SEQUENCE:
subroutine Str2Flt_FmtNumbers(Init,iFmtCnt,cFmtSub,iFmtLen)
INPUTS:
iFmtCnt integer # numbers collected
cFmtSub character*(*) format fitting numbers
iFmtLen integer # characters in number
OUTPUTS:
iFmtCnt integer set to zero
CALLS: ***
Int2Str, Str2Str, itrim
CALLED BY:
Str2Dbl, Str2Flt, Str2Flt_Exp, Str2Flt_FforI, Str2Flt_Int, Str2Flt_Mask
Str2Flt_XforA, Str2Int
SEE ALSO:
Str2Flt
MODIFICATION HISTORY:
SEP-2002, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
[Previous]
[Next]
NAME:
Str2Flt_Format
PURPOSE:
Extract format set up during last call to Str2Flt
CALLING SEQUENCE:
entry Str2Flt_Format(cFmtOut)
INPUTS:
(none)
OUTPUTS:
cFmtOut character*(*) format fitting input string to last Str2Flt call.
CALLS: ***
Int2Str, Str2Str, itrim
CALLED BY:
BList_NSO_NOAA, BList_WSO_NOAA, DailyIPS_UCSD [1], DailyIPS_UCSD [2], Pandora
iFltArr, smei_frm_path
PROCEDURE:
Entry point in subroutine Str2Flt_FmtNumbers
MODIFICATION HISTORY:
DEC-1992, Paul Hick (UCSD), converted from IDL
[Previous]
[Next]
NAME:
Str2Flt_Int
PURPOSE:
Deterimines how integers in the next Str2Flt are interpreted.
CALLING SEQUENCE:
entry Str2Flt_Int(bIntIn)
INPUTS:
bIntIn logical default: .FALSE.
CALLS: ***
Int2Str, Int2StrSet, Say, Str2Flt_CheckNext, Str2Flt_FmtCrumbs, Str2Flt_FmtNumbers
Str2Str, itrim, uppercase
SEE ALSO:
See Str2Flt
RESTRICTIONS:
Valid for one call to Str2Flt only.
PROCEDURE:
Entry point in subroutine Str2Flt
If bInt=.TRUE. then integer values are equivalenced
to a real*4. The real*4 value is then returned in the
output array rVec of Str2Flt
MODIFICATION HISTORY:
DEC-1992, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
[Previous]
[Next]
NAME:
Str2Flt_Mask
CALLING SEQUENCE:
entry Str2Flt_Mask(cMaskIn)
CALLS: ***
Int2Str, Int2StrSet, Say, Str2Flt_CheckNext, Str2Flt_FmtCrumbs, Str2Flt_FmtNumbers
Str2Str, itrim, uppercase
CALLED BY:
DailyIPS_UCSD [1], DailyIPS_UCSD [2]
PROCEDURE:
Entry point in subroutine Str2Flt
MODIFICATION HISTORY:
DEC-1992, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
[Previous]
[Next]
NAME:
Str2Flt_XforA
PURPOSE:
Set the value of bXforA for one call to Str2Flt (def: .FALSE.)
CALLING SEQUENCE:
entry Str2Flt_XforA(bXforAIn)
INPUTS:
bXforAIn logical uninterpreted chars are identified with:
.TRUE. : 'X' in cFmt
.FALSE. : 'A' in cFmt
OUTPUTS:
(none)
CALLS: ***
Int2Str, Int2StrSet, Say, Str2Flt_CheckNext, Str2Flt_FmtCrumbs, Str2Flt_FmtNumbers
Str2Str, itrim, uppercase
RESTRICTIONS:
Valid for one call to Str2Flt only; before returning values are set
back to defaults)
PROCEDURE:
Entry point in subroutine Str2Flt
MODIFICATION HISTORY:
DEC-1992, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
[Previous]
[Next]
NAME:
Str2Int
PURPOSE:
Extract numbers from string and put them in integer array
CALLING SEQUENCE:
entry Str2Int(cStr,nVec,iVec)
INPUTS:
cStr string (e.g. 89/1/12)
nVec integer max # elements read into rVec
OUTPUTS:
nVec integer # elements of rVec filled
If more than nVec numbers were located in the input
string, then nVec is set to the NEGATIVE of the
input value of nVec.
iVec integer integer array with identified numbers
CALLS: ***
Int2Str, Int2StrSet, Say, Str2Flt_CheckNext, Str2Flt_FmtCrumbs, Str2Flt_FmtNumbers
Str2Str, itrim, uppercase
CALLED BY:
ForeignI2ArgN, ForeignI4ArgN
PROCEDURE:
Integer version of Flt2Str
[Previous]
[Next]
NAME:
Str2Str
PURPOSE:
Copy string to another string
CATEGORY:
Strings: write string to string
CALLING SEQUENCE:
integer function Str2Str(cStr1,cStr2)
INPUTS:
cStrI character*(*) string to be processed
OUTPUTS:
Str2Str integer length non-trivial part of output string
CALLS: ***
itrim
CALLED BY:
AskLimit, BList_NSO_NOAA, BList_WSO_NOAA, BuildSourceSurface, CheckMass, Connect
GridFill, HERDISK, HOSPlot_bCommand, LOSClean, LOSTweak, MAP_TZERO, NicHdr
ParseRepair, Peep, ReadVIPS, ReadVIPSLOSCheck, ReadVIPSLOSCheckn, ReadVIPSn, SD
SD_SCAN, SD_TREE, SetRotations, SortIPS, Str2Dbl, Str2Flt, Str2Flt_Crumbs, Str2Flt_Exp
Str2Flt_FforI, Str2Flt_FmtCrumbs, Str2Flt_FmtNumbers, Str2Flt_Format
Str2Flt_Int, Str2Flt_Mask, Str2Flt_XforA, Str2Int, T3D_fill_global, T3D_fill_time
T3D_get, T3D_get_all, T3D_get_grid, T3D_get_mode, T3D_header, T3D_iget, T3D_iset
T3D_marker, T3D_set, T3D_set_mode, T3D_write_nv, TheFit, Time2CarringtonT0
Write3D_nv_UT, Write3D_nv_XC, WriteI4GRD, WriteR4GRD, XCvarFormat, bCompressNic
dailyips [1], dailyips [2], iDir2File, iFile2Dir, iFilePath, iFileStructure, iFltArr
iGetDirectoryFragment, iGetFileSpec, iGetParentDirectory, iGetTopDirectory
iOSCopyFile, iOSgunzip, iSetFileSpec, ice_read, ice_write, ipsd, ipsg2, ipsg2s, ipsg2t
mkenv, rice, smei_base, smei_cal, smei_cal_add, smei_cal_build, smei_cal_c3mask
smei_cal_get, smei_cal_init, smei_cal_read, smei_frm_base, smei_frm_getlist
smei_frm_ok, smei_frm_write, smei_get_glare, smei_orb, smei_orb_mkname, smei_skyd
smei_skyd_combine, smei_skyd_fill, smei_skyd_flush, smei_skyd_fts
smei_skyd_init, smei_skyd_make, smei_skyd_scan, smei_skyd_size, smei_skyd_sky
smei_skyd_sort, sprint
SEE ALSO:
Flt2Str, Int2Str, Int2StrSet, Str2StrSet
INCLUDE:
include 'str2str_inc.h'
PROCEDURE:
The input string cStrI is put in the output string subject to the
constraints set by Str2StrSet.
A sequence of Str2Str, Int2Str and Flt2Str calls can be used to build
a string without explicitly referring to locations in the destination
string:
I = 0
I = I+Str2Str(cStr1, cStrO(I+1:))
I = I+Int2Str(iNum , cStrO(I+1:))
I = I+Str2Str(cStr2, cStrO(I+1:))
MODIFICATION HISTORY:
JAN-1995, Paul Hick (UCSD)
[Previous]
[Next]
NAME:
str2str_inc
PURPOSE:
Define parameter constants
SEE ALSO:
Int2Str, Str2Flt, Str2Str
CALLING SEQUENCE:
include 'str2str_inc.h'
INCLUDED BY:
AskLimit, Connect, Dbl2Str, Flt2Str, Int2Str, ParseRepair, SetRotations, Str2Flt
Str2Str, T3D_get_grid, T3D_marker, T3D_marker_num, TheFit, XCvarFormat, bOSFind
iDir2File, iFile2Dir, iFilePath, iFltArr, iSetFileSpec
PROCEDURE:
[Previous]
[Next]
NAME:
Str2StrSet
PURPOSE:
Set mode of string insertion in Str2Str
CALLING SEQUENCE:
entry Str2StrSet(nFill)
INPUTS:
iSet integer insertion mode; default: STR__TRIM
Any of the values in include file
str2str_inc.h can be used: STR__TRIM,
STR__NOTRIM,STR__LEFTADJUST,STR__RIGHTADJUST
OUTPUTS:
Str2StrSet integer previous insertion mode
CALLS: ***
itrim
CALLED BY:
AskLimit, Connect, ParseRepair, SetRotations, TheFit, bOSFind, bOSFindClose, iDir2File
iFile2Dir, iFilePath, iFileStructure, iFltArr, iGetDirectoryFragment, iGetFileSpec
iGetParentDirectory, iGetTopDirectory, iSetFileSpec
SEE ALSO:
Int2Str, Int2StrSet, Str2Str
PROCEDURE:
Str2StrSet is an entry point in function Str2Str.
Typically it is used before and after one or more Str2Str calls to
restore a previously set insertion mode:
iSet = Str2StrSet(STR__NOTRIM) Set new insertion mode, save old one
( calls to Str2Str )
iSet = Str2StrSet(iSet) Restore old insertion mode
MODIFICATION HISTORY:
JAN-1995, Paul Hick (UCSD)
[Previous]
[Next]
NAME:
sun
PURPOSE:
Defines parameter constants for various solar constants
INCLUDED BY:
AIPS_WTF, BList_NSO_NOAA, BList_WSO, BList_WSO_NOAA, ECLIPTIC_HELIOGRAPHIC
ECLIPTIC_HELIOGRAPHIC8, ExtractInsitu, GIPSCAST, GIPSIMP, IPSBase, JD_SYNC
KeplerOrbit, LOSPosition, LOSWeights, MAP_CarrTime, N_CARRINGTON, PA_POLE, READ_HOS
ReadG, ReadGHD, SW_Model_Kinematic, SetGipsy, SetGrid, SunRadius, T3D_Read_B
Thomson3DDensity, ThomsonLOS, ThomsonLOS3D, ThomsonLOS3DStep, ThomsonLOSFar
ThomsonLOSStep, ThomsonS10, Time2Carrington, Time2EclipticHeliographic
Time2KeplerOrbit, Time2PAnglePole, Time2SunRadius, Time2smei_eph, UlyssesOrbit
Write3D_bb, Write3D_bb_UT, Write3D_bb_XC, Write3D_bbtt, iReadNagoya, iReadNagoyan
iReadOoty, iReadOotyn, iReadUCSD, ipsd, ipsdt, mapcoordinates, smei_eclipse
[Previous]
[Next]
NAME:
SUN_L0B0
PURPOSE:
Calculate heliographic coordinates of center of the solar disk
CALLING SEQUENCE:
subroutine SUN_L0B0(iYr,Doy, L0,B0)
INPUTS: (angles in degrees)
iYr integer year
Doy real doy of year (including fraction for time of day)
L0 real ecliptic longitude offset of observer
(see procedure)
B0 real ecliptic latitude of observer
OUTPUTS: (angles in degrees)
L0 real heliographic longitude and ..
B0 real .. latitude of observer
CALLS: ***
ECLIPTIC_HELIOGRAPHIC, SunNewcomb
PROCEDURE:
The position of the observer is specified in heliocentric ecliptic
coordinates relative to the Earth, i.e. L0 is the difference between
the eclip. long. of the observer and ecl. long. of Earth.
Set L0=0 and B0=0 to get the conventional L0 and B0 (disk center as
seen from Earth, or sub-Earth point).
MODIFICATION HISTORY:
JUN-1993, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
[Previous]
[Next]
NAME:
SunFlux
PURPOSE:
Reads file SUN10.DAT from Neckel & Labs 1984 Sol. Phys.
90, 205 and converts into photons/sq m/sec/band for a
solar-type star of V mag = 15.00.
CATEGORY:
CALLING SEQUENCE:
program SunFlux ! Conversion of solar irradiance to photons.
INPUTS:
OUTPUTS:
CALLS:
PROCEDURE:
MODIFICATION HISTORY:
Written 90 Apr 24 by Robert S. McMillan, LPL/U. Arizona
[Previous]
[Next]
NAME:
SunNewcomb
PURPOSE:
Calculates the true ecliptic coordinates (longitude, latitude and
distance) of the Sun according to Newcombs theory of solar motion.
See O. Montenbruck, Practical Ephemeris Calculations, par. 4.1.2, p. 66.
CATEGORY:
Celestial mechanics
CALLING SEQUENCE:
subroutine SunNewcomb(ID,iYr,Doy,rLng,rLat,rDis)
CALLS: ***
Julian, dcosd, dsind
INPUTS:
ID integer 0 = return two-body solution
1 = take planetary perturbations into account
iYr integer year
Doy real doy of year, including fraction for time of day
OUTPUTS:
rLng double precision ecliptic longitude in degrees [0,360)
rLat double precision ecliptic latitude in arcsec
rDis double precision Sun-Earth distance in AU
CALLED BY:
BList_NSO_NOAA, BList_WSO_NOAA, EARTH, EARTH_ELIMB, EARTH_WLIMB, ExtractPosition
JD_SYNC, Pandora, ReadG, SUN_L0B0, SunRadius, iProcessNagoya, iProcessNagoyan
iProcessOoty, iProcessOotyn, iProcessUCSD, iReadNagoya, iReadNagoyan, iReadOoty
iReadOotyn, iReadUCSD, ipsd, ipsdt
PROCEDURE:
DLP long period perturbation of solar mean longitude and mean
anomaly
G mean anomaly of the Sun
LO = DLO+SLO/3600 = mean longitude of Sun
DL difference between true and mean solar longitude according to
two body problem
The precision calculation includes perturbations by planets, oscillatory
terms with amplitudes less than 8 arcsec.
ACCURACY:
A check with the Astronomical Almanac shows:
(All times are at midnight on the day given)
Normal Precision Almanac
1971 Jan 1 Lng 279.9114 279.91575 279 54' 57.0" (279.91583)
Lat 0. 0.38" 0.42"
Dist 0.9832947 0.9833006 0.9832998
1974 Jan 1 Lng 280.1882 280.1874 280 11' 14.94" (280.1875)
Lat 0.
Dist
1979 Jan 1 Lng 279.9702 279.9708 279 58' 14.90" (279.9708)
Lat 0.
Dist
1989 Jan 1 Lng 280.5535 280.5525 280 33' 10.44" (280.5529)
Lat 0.
Dist
MODIFICATION HISTORY:
1989, Paul Hick (MPAE,UCSD/CASS; pphick@ucsd.edu)
10/24/91, Tom Davidson : accuracy test
AUG-1993, Paul Hick, extension of SunEclLong
[Previous]
[Next]
NAME:
SunNewcomb8
PURPOSE:
Calculates the true ecliptic coordinates (longitude, latitude and
distance) of the Sun according to Newcombs theory of solar motion.
See O. Montenbruck, Practical Ephemeris Calculations, par. 4.1.2, p. 66.
CATEGORY:
Celestial mechanics
CALLING SEQUENCE:
subroutine SunNewcomb8(ID,iYr,Doy8,rLng,rLat,rDis)
CALLS: ***
Julian8, dcosd, dsind
INPUTS:
ID integer 0 = return two-body solution
1 = take planetary perturbations into account
iYr integer year
Doy8 double precision doy8 of year, incl. fraction for time of day
OUTPUTS:
rLng double precision ecliptic longitude in degrees [0,360)
rLat double precision ecliptic latitude in arcsec
rDis double precision Sun-Earth distance in AU
CALLED BY:
EARTH8, ExtractPositionn8
PROCEDURE:
DLP long period perturbation of solar mean longitude and mean
anomaly
G mean anomaly of the Sun
LO = DLO+SLO/3600 = mean longitude of Sun
DL difference between true and mean solar longitude according to
two body problem
The precision calculation includes perturbations by planets, oscillatory
terms with amplitudes less than 8".
ACCURACY:
A check with the Astronomical Almanac shows:
(All times are at midnight on the day given)
Normal Precision Almanac
1971 Jan 1 Lng 279.9114 279.91575 279 54' 57.0" (279.91583)
Lat 0. 0.38" 0.42"
Dist 0.9832947 0.9833006 0.9832998
1974 Jan 1 Lng 280.1882 280.1874 280 11' 14.94" (280.1875)
Lat 0.
Dist
1979 Jan 1 Lng 279.9702 279.9708 279 58' 14.90" (279.9708)
Lat 0.
Dist
1989 Jan 1 Lng 280.5535 280.5525 280 33' 10.44" (280.5529)
Lat 0.
Dist
MODIFICATION HISTORY:
1989, Paul Hick (MPAE,UCSD/CASS; pphick@ucsd.edu)
10/24/91, Tom Davidson : accuracy test
AUG-1993, Paul Hick, extension of SunEclLong
[Previous]
[Next]
NAME:
SUNRA
PURPOSE:
Calculate sidearal time and position of the Sun.
Good for years 1901 through 2099. Accuracy is 0.006 degree.
CATEGORY:
Celestial mechanics
CALLING SEQUENCE:
subroutine SUNRA(iYr,iDay,SECS,GST,SLONG,SRASN,SDEC)
INPUTS:
iYr integer
iDay integer
SECS real (iYr,iDay,SECS) define the universal time (UT)
OUTPUTS:
GST real Greenwich sidereal time (degrees)
SLONG real Ecliptic longitude Sun (degrees)
SRASN real Apparent right ascension Sun (degrees)
SDEC real Apparent declination (degrees)
INCLUDE:
include 'math.h'
RESTRICTIONS:
Only valid for years 1901 through 2099
MODIFICATION HISTORY:
From: Geophysical Coordinate Transformations, C.T. Russell, in:
Cosmic Electrodynamics 2 (1971) 184-196
[Previous]
[Next]
NAME:
SunRadius
PURPOSE:
Calculate radius of Sun (in arcseconds) as seen from Earth
CALLING SEQUENCE:
function SunRadius(iYr,Doy)
INPUTS:
iYr integer year
Doy integer doy of year (fraction for time of day)
OUTPUTS:
SunRadius real solar radius in arcsec at time iYr,Doy
INCLUDE:
include 'sun.h'
include 'math.h'
CALLS: ***
SunNewcomb
PROCEDURE:
The Earth-Sun distance is calculated by calling SunNewcomb
MODIFICATION HISTORY:
AUG-1993, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
[Previous]
[Next]
NAME:
surf_MOD
PURPOSE:
To make a set of boundary maps of velocity and density at the bottom of the
MODEL for use by the MODEL as input for the parameters (outward velocity
and density) that the tomography program can provide.
The subroutine is inserted into the MODEL subroutine and is passed the MODEL
parameters of MODEL array and the MODEL time (IYR, DOY) and the MODEL beginning
longitude (ICTX, FICTX). The program assumes that both the 0 degree and 360
degree ends of the MODEL array are present (LOINC = 1, LAINC = 1) or not
(LOINC = 0, LAINC = 0). The subroutine is also passed the tomography program
parmeters that are needed and the tomography base velocities and densities.
The subroutine outputs the results needed by the MODEL program as a base
velocity and density at the resolution of the MODEL program and in the
MODEL inertial coordinates.
CATEGORY:
Data processing
CALLING SEQUENCE:
call surf_MOD(NLNGM,NLATM,NMAPM,IYR,DOY,ICTX,FICTX,
XCbe,XCtbeg,XCtend,nLng,nLat,nT,nCar,JDCar,NCoff,vv,dd,
V3,D3)
INPUTS:
THESE ARE MODEL INPUTS
NLNGM integer # of model longitude points (inertial frame includes 0 but not 360 deg.)
NLATM integer # of model latitude points (inertial frame from -90 to + 90 deg.)
NMAPM integer # of model heights
IYR integer Year of the current model calculation (e.g., 20XX) (e.g., 2000)
DOY real Day of year for the current model calculation (begins at 1.0 on the first day)
ICTX integer Beginning Carrington variable source surface at this time. (e.g., 1965)
FICTX real Beginning Carrington variable source surface fraction at this time. (e.g., 0.123)
THESE ARE TOMOGRAPHY INPUTS AND THEIR VALUES
XCbe(2,nT) real Boundary values of time maps
XCtbeg real Beginning time interval
XCtend real Ending time interval
nLng integer # longitude points
nLat integer # latitude points
nT integer # time intervals
nCar intger # beginning Carrington variable Julian dates
JDCar real*8 Carrington variable beginning Julian dates
NCoff integer Carrington variable offset
vv(nLng,nLat,nT)real Map of velocity values at a given height RR
dd(nLng,nLat,nT)real Map of density values at a given height RR
OUTPUTS:
THESE ARE OUTPUTS TO THE MODEL
V3(NLNGM,NLATM,NMAPM,3) real 3D velocity on source surface (level 1) from tomography model in km/sec at ICTX + FICTX
D3(NLNGM,NLATM,NMAPM) real 3D density on source surface (level 1) from tomography model in km/sec at ICTX + FICT
CALLS: ***
EARTH, FLINT, XMAP_SC_POS
CALLED BY:
sim_MOD
PROCEDURE:
MODIFICATION HISTORY:
May-2002, B. Jackson (UCSD)
[Previous]
[Next]
NAME:
SW_Model_DevFromR2
CALLING SEQUENCE:
function SW_Model_DevFromR2(D,V)
INPUTS:
D real normalized density
V real velocity
OUTPUTS:
SW_Model_DevFromR2
real forces a density drop-off as 1/r^(2+SW_Model_DevFromR2)
CALLED BY:
SW_Model_Kinematic
SEE ALSO:
SW_Model_DevFromR2_Define
PROCEDURE:
Using the constants set by SW_Model_DevFromR2_Define an incremental
power dP is determined.
For V <= Vmin, dP = dPVmin
For V >= Vmax, dP = dPVmax
For Vmin < V < Vmax, a linear interpolation between dPVmin and dPVmax is done.
The same is done for the density. The contributions for velocity and density
are added together.
MODIFICATION HISTORY:
APR-2002, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
[Previous]
[Next]
NAME:
SW_Model_DevFromR2_Define
CALLING SEQUENCE:
entry SW_Model_DevFromR2_Define(dPVmin_,Vmin_,dPVmax_,Vmax_,dPDmin_,Dmin_,dPDmax_,Dmax_)
SEE ALSO:
SW_Model_DevFromR2
PROCEDURE:
Entry point in SW_Model_DevFromR2
MODIFICATION HISTORY:
APR-2002, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
[Previous]
[Next]
NAME:
SW_Model_Kinematic
PURPOSE:
Creates a solar wind model from density and velocity map at the source
surface. Output is the 3D density and velocity and a 'shift array'
to be used in determination of source locations at the source surface.
The shift array gives for each grid point the average longitude shift in
fractions of a rotation required to get to the source surface.
CATEGORY:
Tomography: solar wind model
CALLING SEQUENCE:
subroutine SW_Model_Kinematic(I__VD,XCbegMAT,XCendMAT,VV,G2,XC3D,V3D,D3D,XTtmp)
INPUTS:
I__VD
XCbegMAT(nTim) real start Carrington variable of matrix (- NCoff)
XCendMAT(nTim) real end Carrington variable of matrix (- NCoff)
(range of matrix typically is three Carrington rotations)
VV(nLng,nLat,nTim) real Velocity map at at source surface RR
G2(nLng,nLat,nTim) real g^2 map at at source surface RR
XTtmp(nLng,nTim,2) real Scratch array
OUTPUTS:
XC3D(3,nLng,nLat,nRad,nTim) real Shifts in terms of fractions of a Carrington rotation
V3D (nLng,nLat,nRad,nTim) real 3D velocity matrix
G23D(nLng,nLat,nRad,nTim) real 3D g^2 matrix
CALLS: ***
ArrR4Copy, ArrR4Zero, BadR4, CheckMass, CvD2G, CvG2D, FLINT, GridSphere2D
SW_Model_DevFromR2, Say, T3D_get, T3D_get_grid, T3D_iget
CALLED BY:
ipsg2, ipsg2s, ipsg2t
INCLUDE:
include 'sun.h'
include 't3d_param.h'
include 't3d_array.h'
include 't3d_index.h'
include 't3d_grid_fnc.h'
include 't3d_loc_fnc.h'
RESTRICTIONS:
> If nTim = 1 (time-independent reconstruction; then dTT should be set to zero (dTT = 0).
> I think there is an implicit assumption that XCendMAT(i)-XCbegMAT(i) is the same
for all times i=1,nTim.
> There is NO CHECK for bad values (BadR4()) in VV and G2. Hence, the caller must make
sure that these two input array do not have any holes.
PROCEDURE:
> ClipLng should be set to zero if iand(MODE,TOM__MOD) > 0, and to some non-zero
value (90 deg?) if not
> XC3D(I,J,N) is the shift needed to trace location (I,J,N) back to the reference
surface, i.e. XC = XCvar(I)+XC3D(I,J,N) defines the origin of point (I,J,N)
at the reference surface in terms of a modified Carrington variable.
XC3D(I,J,N) will be negative above the reference surface (N > 1) and zero
at the reference surface (N = 1).
> The input array VV and G2 should not have any holos (BadR4() values) in them
> G2 (g^2) is converted to normalized density right at the start. 3D density,
velocity and shift arrays are then build up stepping from one heliocentric distance
level to the next working from the source surface up to the outer boundary.
Before returning the density array is converted back to g^2.
> Once a level is finished holes at that level are filled with GridSphere2D before
continuing to the next level.
MODIFICATION HISTORY:
MAR-1997, B. Jackson (UCSD/CASS) (original name was MAKE_TS)
MAY-1998, Paul Hick (UCSD/CASS); serious revision
AUG-2001, Paul Hick (UCSD/CASS; pphick@ucsd.edu); modified for time-dependent tomography
[Previous]
[Next]
NAME:
SwitchTag
PURPOSE:
Given two tags, check for presence of one of the tags and replace it with the other.
CATEGORY:
Strings: tag manipulation
CALLING SEQUENCE:
subroutine SwitchTag(cTags,cSep,cTag1,cTag2)
INPUTS:
cTags character*(*) list of tags, separated by the cSep character
cSep character character used as separater (usually comma)
cTag1,cTag2 character*(*) tags (substrings) to be switched
OUTPUTS:
cTags character*(*) updated list of tags (RemoveTag, SwitchTag only)
CALLS: ***
LocateTag, ReplaceTag, itrim
SEE ALSO:
RemoveTag
PROCEDURE:
One of the two tags must be present in the cTags list. It will be replaced by the other
MODIFICATION HISTORY:
NOV-1994, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
JUN-1995, Paul Hick (UCSD; pphick@ucsd.edu), added SwitchTag