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 cmask = ' ' if smei_frm_c3mask_active returns 0 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 OCT-2009, John Clover (UCSD/CASS; jclover@ucsd.edu) C Added mask 2009_260 C APR-2010, John Clover (UCSD/CASS) C Added mask 2010_098 C OCT-2010, John Clover (UCSD/CASS) C Added mask 2010_259 C MAR-2011, John Clover (UCSD/CASS) C Added mask 2011_038 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 = 16) ! 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. ! (1) ! 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 do not need a "mask-in" pattern ! for the preceeding calibration. ! (2) & '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 do not need a "mask-in" pattern for the ! preceeding calibration. ! (3) & '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 ! (4) & '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 do not need a "mask-in" pattern for the ! preceeding calibration. ! (5) & '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. ! (6) & '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. ! (7) & '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 do not need a "mask-in" pattern ! for the preceeding calibration. ! (8) & '2008_247_025152','2009_044_130000', '2008_247_025152','2009_044_130000', '2008_226_000000', ! Upload of the 8th mask (2009_014) failed in the data gap between 2009_044_012100 ! and 2009_044_134725. The mask is succesfully uploaded on 2009_052. The flatfield stays ! "off" from 2009_044_134725 to 2009_057_000000 (after a 12-hour anneal starting ! 2009_056_051500). The data after the anneal are processed with the post-anneal ! pattern ???, so we do not need "mask-in" patterns for the weekly calibrations on ! 2009_049 and 2009_056. ! (Around doy 056 and 057 there was a problem with timestamps on 22 L1A files. These ! were not put into the data base. This explains the sparsity of data on these days.) ! (9) & '2009_055_234652','2009_142_234500', '2009_055_234652','2009_142_234500', '2009_014_000000', ! The flatfield is "off" from 2009_142_234500 up to 2009_216_234500 (eclipse season). ! The cal at 2009_140_020000 is the last pre-eclipse cal (with mask-in pattern ! present). The cal at 2009_217_020000 is the first post-eclipse cal. ! The cal at 2002_2011_020000 gets a "mask-in" pattern to process the FF "on" frames ! between 2009_216_234500 and 2009_217_000000. ! (10) & '2009_216_234500','2009_278_140000', '2009_211_000000','2009_278_140000', '2009_014_000000', ! Upload of the 9th mask (2009_260) occurred after 2009_278_134500. The flatfield is 'off" ! from 2009_278_120030 to 2009_281_210905. The first cal after the upload, ! c3cal_2009_280_044811.fts.gz, needs a 'mask-in' pattern using the new mask. ! (11) & '2009_278_140001','2010_113_150000', '2009_278_140001','2010_113_150000', '2009_260_000000', ! Upload of the 10th mask (2010_098) occurred after 2010_113_150000. The flatfield is "off" ! from 2010_113_132708 (first FF "off" frame) until 2010_116_032955 (last FF "off" frame; ! followed by a few FF "on" frames for mode 0). The first cal requiring the new mask is ! on 2010_116_020000. ! (12) & '2010_113_150001','2010_139_234500', '2010_113_150001','2010_139_234500', '2010_098_000000', ! The flatfield is "off" from 2010_139_134500 up to 2010_213_134500 (eclipse season). ! The cal at 2010_137_020000 is the last pre-eclipse cal (with mask-in pattern ! present). The cal at 2010_214_020000 is the first post-eclipse cal. ! The cal at 2010_209_020000 gets a "mask-in" pattern to process the FF "on" frames ! between 2010_213_234500 and 2010_214_000000. ! (13) & '2010_213_134500','2010_276_140000', '2010_209_000000','2010_276_140000', '2010_098_000000', ! Upoad of the 11th mask (2010_259) occurred after 2010_276_135500. The flatfield is "off" ! from 2010_276_122150 (first FF "off" frame) until 2010_277_032955 (last FF "off" frame; ! followed by a few FF "on" frames for mode 0). The first cal requiring the new mask is ! on 2010_277_020000. ! (14) & '2010_276_140001','2011_055_132000', '2010_276_140001','2011_055_132000', '2010_259_000000', ! Upload of the 12th mask (2011_038) occurred after 2011_055_132000. FF is "on" right up to ! the upload: last pre-upload frame 2011_055_125308 has FF "on"; first post-upload frame ! 2011_055_134156 has FF "off". The first FF "on" frame for the mask is 2011_055_234456. ! (15) & '2011_055_132000','2011_140_234500', '2011_055_132000','2011_140_234500', '2011_038_000000', ! The flatfield is "off" from 2011_140_1345 until ??? (eclipse season). ! (16) & '2011_200_234500','2050_001_000000', '2011_200_234500','2050_001_140000', '2011_038_000000'/ ! The 1.08 for masks 2008_226 and 2009_014 have been copied from the preceeding ! mask and still need to be confirmed (pph@2008/10/08 & pph@2009/03/02 & pph@2011/06/18). ! 1 2 3 4 5 6 7 8 9 10 real fmask(NT) /1.020,1.020,1.050,1.057,1.021,1.090,1.080,1.080,1.080,1.080, & 1.080,1.080,1.080,1.080,1.080,1.080/ 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