C+ C NAME: C smei_frm_c3mask_active C PURPOSE: C Check whether camera 3 mask is active at specified time C CATEGORY: C gen/for/lib/frm C CALLING SEQUENCE: integer function smei_frm_c3mask_active(ipatt,tframe,flat_enabled,cmask,fudge) C INPUTS: C ipatt integer 0: use exact range of "bad-pixel" mask periods C 1: use extended range of "bad-pixel" mask periods C for use by smei_cal C tframe character*(*) SMEI frame time in format YYYY_DOY_hhmmss C flat_enabled integer nint(hdr(SMEI__HDR_FLAT_ENABLED)) or -1 C if set to -1 this argument is ignored C if set to the "flat_enabled" flag from a C SMEI frame then this flag is tested in C addition to the time. C OUTPUTS: C smei_frm_c3mask_active C integer 1: bad pixel mask in use for specified time C 0: no bad pixel mask in use for specified time C cmask character*(*) mask time in format YYYY_DOY_hhmmss C This is used in the construction of the file C name for the mask. C fudge real fudge factor for mask C INCLUDE: include 'smei_frm_layout.h' C PROCEDURE: C A camera 3 "bad pixel" mask is in effect onboard during specific C periods, and since it is applied as a "flatfield" it is only C used if the "flatfield-enabled" flag is set in a SMEI frame. C The time periods are hardcoded in this routine. C C If flat_enabled = -1 then only the time 'tframe' is checked: C if the time is inside one of the time periods then C smei_frm_c3mask_active = 1 is returned. Otherwise 0 is returned. C (this is used in href=smei_cal=). C C If flat_enabled = 0 or 1 then the flatfield flag is tested also: C C If flat_enabled = 0 then always smei_frm_c3mask_active=0 is C returned (the mask is present, but is not applied) C C If flat_enabled = 1 then smei_frm_c3mask_active is 1 only if the C time 'tframe' is inside one of the "bad pixel mask" periods C (the mask is present and is applied). C C If a new mask is added to this routine than all SMEI Fortran C programs need to be recompiled. This includes smei_base, C smei_cal, smei_orb and smei_skyd. C C Modification 2008/10/09: transitions between masks was changed C considerably. A number of patterns were recreated: C 2006_038_085451 removed "mask-in" pattern C 2006_053_044615 ,, C 2006_134_114227 ,, C 2006_256_042123 ,, C 2007_101_044631 different mask for "mask-in" pattern C ================================== C 2007_136_044747 - 2007_250_044827 C total of 17 patterns: removed "mask-in" pattern C ================================== C 2008_044_044547 removed "mask-in" pattern C 2008_051_034355 removed "mask-in" pattern C ================================== C 2008_156_040215 - 2008_240_043351 C total of 13 patterns: removed "mask-in" pattern C MODIFICATION HISTORY: C MAR-2007, Paul Hick (UCSD/CASS) C APR-2007, Paul Hick (UCSD/CASS) C Added argument ipatt. C NOV-2007, Paul Hick (UCSD/CASS) C Added mask 2007_237 C JUL-2008, Paul Hick (UCSD/CASS) C Added mask 2008_023 C OCT-2008, Paul Hick (UCSD/CASS; pphick@ucsd.edu) C Added mask 2008_226 C- integer ipatt character*(*) tframe integer flat_enabled character*(*) cmask real fudge ! Number of time periods where a "bad pixel" mask was in effect ! Note that there seven different masks; the first two time periods ! use the same mask 2005_342. parameter (NT = 8) ! tmask(5,*): name of mask ! tmask(1,*) - tmask(2,*): time period where the mask is in ! effects, i.e. frames in this time period with the onboard-flat- ! field flag enabled are using the mask ! tmask(3,*) - tmask(4,*): only used by smei_cal. For calibration ! patterns inside this time range, a pattern is made with the ! mask in effect. The time of the first frame used for pattern ! construction is used to decided whether or not to add the ! the "masked" calibration pattern. In most cases ! tmask(3,*) = tmask(1,*) and tmask(4,*) = tmask(2,*) ! (see explanation below) ! If possible only calibrations inside the time range tmask(1,*) to ! tmask(2,*) should be used to process the "mask-in" frames in the same ! time range. For the beginning of a "bad-mask" period this usually means ! that a couple of days of data need to be processed with smei_base using ! a calibration pattern LATER than the frame times (by default the ! preceeding pattern is used). Unless the "bad-mask" periods starts with ! a calibration pattern, this requires a special run with smei_base ! explicitly specifying the pattern and setting the c3mask argument to one. ! (see script c3base). In addition a special run with smei_orb needs ! to be setup with the minimum pattern set close to the pattern actually ! used by smei_base (see script c3orb). For these cases ! tmask(3,*) = tmask(1,*) and tmask(4,*) = tmask(2,*) ! If there is no adequate calibration pattern available near the ! beginning or end of the "bad-mask" period tmask(1,*) - tmask(2,*) ! then a pattern outside this range needs to be selected. This is ! for instance the case for the 1-day test period for the first mask. ! For these cases tmask(3,*) is set to the beginning of the ! calibration preceeding tmask(1,*); and tmask(4,*) is set to the end ! of the calibration following tmask(2,*). If it is necessary to ! to use a pattern later than tmask(3,*) to process the end of a ! "bad-mask" period than special runs of smei_base and smei_orb ! need to be set up for the corresponding period as explained ! above. ! Note that it is imperative that the special runs of smei_base and ! and smei_orb need to be consistent with the time periods in this ! file. If it is done incorrectly than smei_sky may not find the ! correct pattern (and bail) or use a "mask-out" pattern for ! "mask-in" pattern (leading to a invalid skymap). character tmask(5,NT)*(SMEI__UT_FORMAT_LEN) ! The first "bad pixel" mask was tested from 2006_033_00 - 2006_034_00 ! The preceeding calibration 2006_032_034719 is used by smei_base and smei_orb ! so we need a "mask-in" pattern for that calibration. ! Start time End time Previous cal Next cal Mask name & /'2006_033_000000','2006_033_235959', '2006_032_034718','2006_033_235959', '2005_342_000000', ! Test period ! 2nd "bad-pixel" mask period (using the same mask 2005_342) starts ! at 2006_053_234500 (with the first frames with onboard flatfield ! enabled starting 2006_054_000000), and ends with the breakdown of ! DHU-A around 2006_090_09000. There are no data until 2006_125_200000. ! The time period 2006_053_234500 - 2006_060_043111 is processed by ! smei_base using calibration pattern 2006_060_043111 (see script ! c3base), and smei_orb uses a minimumum orbit close to the ! calibration (see script c3orb), so we don't need a "mask-in" pattern ! for the preceeding calibration. & '2006_053_234500','2006_091_000000', '2006_053_234500','2006_091_000000', '2005_342_000000', ! Ends when DHU-A fails ! DHU-B picks up around 2006_125_20000. The 2nd mask is uploaded ! around 2006_260, and becomes active on 2006_261_203602 (after a ! 2-day data gap). ! Between 2006_125_200000 and 2006_261_203602 the flatfield is "off" ! except for one orbit on doy 134 (mode 0) and on doy 150 and 151 ! (mode 1) during which the pre-launch flatfield is used. ! The time period 2006_261_195846 - 2006_263_035731 is processed by ! smei_base using calibration c3cal_2006_263_035731 (see script ! c3base), and smei_orb uses a minimum orbit close to the calibration ! (see script c3orb), so we don't need a "mask-in" pattern for the ! preceeding calibration. & '2006_261_195846','2006_333_235959', '2006_261_195846','2006_333_235959', '2006_215_000000', ! Transition from 2nd to 3th mask is at 2006_334 with a calibration ! starting at 2006_334_000000 ! Calibration at beginning of 2006_333 is done with 3th mask ! Calibration at beginning of 2006_334 is done with 4th mask & '2006_334_000000','2007_099_150000', '2006_334_000000','2007_099_150000', '2006_334_000000', ! Transition from 3rd to 4th mask is set to 2007_099_150000 in a data ! gap between 2007_099_124708 and 2007_099_160819 (when the upload ! was done). ! The time period 2007_099_150000 - 2007_101_04463 is processed by ! smei_base using calibration c3cal_2007_101_044631 (see script ! c3base), and smei_orb uses a minimum orbit close to the calibration ! (see script c3orb), so we don't need a "mask-in" pattern for the ! preceeding calibration. & '2007_099_150000','2007_136_000000', '2007_099_150000','2007_136_000000', '2007_083_000000', ! Transition from 4th to 5th mask is at 2007_255_000000 (actually the ! onboard flatfield is "off" between 2007_136_000000 and ! 2007_255_000000). There is a calibration at the beginning of 2007_255. ! The 5th mask ends at 2008_039_140000 with a failed upload of the ! 6th mask. & '2007_255_000000','2008_039_140000', '2007_255_000000','2008_039_140000', '2007_237_000000', ! The first attempt at uploading the 6th mask on 2008_039 failed. ! The second upload on 2008_049 succeeded. In between the science ! mode data with flatfield enabled (2008_040_153000 - 2008_042_174500) ! are no good (these frames have been flagged as bad). The 6th mask ! was first used between 2008_051_051647 and 2008_051_052451 (mode 0) ! and starting 2008_053_175208 for mode 1. ! The pattern c3cal_2008_051_034355 includes a "mask-in" pattern ! to be able to process the brief mode 0 data with flatfield enabled ! starting at 2008_051_051647. ! The time period 2008_053_175208 - 2008_058_040855 is processed by ! smei_base using calibration c3cal_2008_058_040855 (see script ! c3base), and smei_orb uses a minimum orbit close to the calibration ! (see script c3orb), so we don't need a "mask-in" pattern for the ! preceeding calibration. & '2008_051_051646','2008_156_000000', '2008_051_034158','2008_156_000000', '2008_023_000000', ! Transition from 6th to 7th mask is at 2008_247_000000. The flatfield ! is "off" between 2008_156_000000 and 2008_247_025149 (except for a ! brief period of mode 0 frames between 2008_242_182147 and ! 2008_242_182955). The first new "mask-in" frame is at 2008_247_025153 ! (15 minutes before calibration c3cal_2008_247_041127). ! The time period 2008_247_025153 - 2008_247_041127 is processed by ! smei_base using calibration c3cal_2008_247_041127 (see script ! c3base), and smei_orb uses a minimum orbit close to the calibration ! (see script c3orb), so we don't need a "mask-in" pattern ! for the preceeding calibration. & '2008_247_025152','2050_000_000000', '2008_247_025152','2050_000_000000', '2008_226_000000'/ ! The 1.08 for mask 2008_226 has been copied from the preceeding mask ! and still needs to be confirmed (pph@2008/10/08) real fmask(NT) /1.02,1.02,1.05,1.057,1.021,1.09,1.08,1.08/ if (flat_enabled .eq. 0) then smei_frm_c3mask_active = 0 cmask = ' ' fudge = 1.0 else ! Loop over the time periods where a "bad pixel" mask was in effect. j = 1+2*ipatt i = 1 do while (i .le. NT .and. .not. (tmask(j,i) .le. tframe .and. tframe .le. tmask(j+1,i))) i = i+1 end do if (i .le. NT) then ! "Bad pixel" mask active smei_frm_c3mask_active = 1 cmask = tmask(5,i) fudge = 1.0/fmask(i) else ! No "bad pixel mask active smei_frm_c3mask_active = 0 cmask = ' ' fudge = 1.0 end if end if return end