This page was created by the IDL library routine `mk_html_help2`.

Last modified: Wed Aug 27 18:18:07 2025.

# Directory Listing of Routines

# projects/elfin/phase_delay

- ELF_PHASE_DELAY_AUTO
  Compute the best phase delay for an EPDE science collection and update the phase delay ASCII file accordingly.
- ELF_PHASE_DELAY_AUTO_SAVE
  Compute the best phase delay for an EPDE science collection and update the phase delay ASCII file accordingly.

# Routine Descriptions

## ELF_PHASE_DELAY_AUTO

[Next Routine] [List of Routines]

     PROCEDURE:
       elf_phase_delay

     PURPOSE:
       Compute the best phase delay for an EPDE science collection and update the phase delay ASCII file accordingly.

     KEYWORDS:
       probe:              Specify a probe; valid values are 'a' or 'b'.
                           If no probe is specified the default is probe 'a'.
       Echannels:          Specify the desired energy channel bins as a list. If keyword is not set, the default is [0,3,6,9].
       new_config:         Specify a new on-board phase delay correction if it has changed since the previous entry
                           in the calibration file. Do not set this keyword if the on-board correction is unchanged.
                           Must be specified in degrees.
       pick_times:         Set this keyword to manually select a timeframe within the data to perform fits on while
                           running code. If this keyword is not set, the code will use the time interval specified
                           in the "oldtimes" variable. It is recommended to pick an interval around 1 minute in length.
       overwrite_attitude: Set this keyword to indicate a manual override of the attitude data from elf_load_state.
                           The correct attitude must be defined as "correct_att" in the code (GEI) along with its uncertainity (deg).
                           Note: with the new attitude solution generation method, this is likely not needed anymore.
       reprocess:          Set this keyword to run the code in "reprocess" mode only. In this case, medians are computed
                           for any NaNs in previous completed intervals, but no fits are done on the current time selection.
                           To use this mode, the user must run the code on a time interval that falls in the 7-day interval
                           that is next recorded after the interval to reprocess.
       Isolu:              specify a start of inital guess of dSectr2add
                           (default) Isolu=0, initial guess of dSectr2add is [-4,-2,0,2,4]
                           Isolu=1, initial guess of dSectr2add is [-2,0,2,4]
       onlypng:            (default) onlypng=0, pop-up window and save png
                           onlypng=1, only save png
       outputplot:        (default) outputplot=0 save summary plot for all fits (summary_IsoluX_ItersX)
                           outputplot=1 save summary plot for all fits (summary_IsoluX_ItersX) and plots for each iteration (IsoluX_ItersX_XXX)

     EXAMPLES:
       elf_phase_delay, probe='b', Echannels=[3,6,9,12], /pick_times

     NOTES:
       This code only operates on data on or after 2019-04-30 (due to improper MSP configurations prior to
       this time).

       When running this code for the first time on a new science collection interval, the pick_times keyword must be
       turned on in order to manually select a smaller interval to perform the fits on. After selection, the
       user can store these times in the "oldtimes" variable if future runs on the same science collection are
       desired. It is recommended to pick a time interval that does not exceed two minutes in length to keep
       the code running efficiently. The optimal time interval length is around 40-60 seconds.

       After the code determines the correct phase delay, it will first ask if you want to flag it as "bad".
       A result should be flagged as "bad" if the quality of the data prohibits accurate fits to the
       pitch angle distribution. It is advised that the user views the final plot showing fits to the PAD
       for each spin period to determine if a "bad" flag is necessary. Type "y"+Enter to flag the result as
       "bad", or anything else + Enter to not flag.

       The code will then display the chi squared value of the final fits and ask the user if they want to
       record the phase delay corresponding to these fits in the phase delay file, or instead record a
       placeholder value (a median of all the previously computed phase delays with the same on-board
       correction and spin period within 20% of the current spin period of interest). Type "y"+Enter to record
       the computed phase delay, or "n"+Enter to record a placeholder value. Note that if a placeholder is used,
       the user should also flag this result as "bad".

       Lastly, the code will ask if the user would like to add these results to the phase delay file. Type "y"
       +Enter to do so, or "n"+ Enter to refrain from adding this new line to the file. In the latter case,
       the file will simply be re-written with all the pre-existing results after median-reprocessing, if
       applicable.

       Any new entry added to the phase delay file will have NaN values in place of the median sector and
       median phase angle. One must run the code on any time within the NEXT pre-defined 7-day interval (beginning from
       2019-04-30) with EPD data that follows this science collection in order to automatically compute a
       median fit value that is then re-processed into the file. The median calculation for each 7-day interval
       disregards any entries with badFlag=1, and divides the interval into smaller chunks corresponding to the
       same on-board correction and similar spin period if a change is detected.

       Note that dPhAng2add more than +/- 11 does not work. Additional sectors are added at this point.

    +
     :Description:
        Describe the procedure.

     :Keywords:
        pick_times
        new_config
        probe
        Echannels
        overwrite_attitude
        check_nonmonotonic
        sstart
        send
        soldtimes

     :Last edited: Jiashu Wu

(See projects/elfin/phase_delay/elf_phase_delay_AUTO.pro)

## ELF_PHASE_DELAY_AUTO_SAVE

[Previous Routine] [List of Routines]

     PROCEDURE:
       elf_phase_delay

     PURPOSE:
       Compute the best phase delay for an EPDE science collection and update the phase delay ASCII file accordingly.

     KEYWORDS:
       probe:              Specify a probe; valid values are 'a' or 'b'.
                           If no probe is specified the default is probe 'a'.
       Echannels:          Specify the desired energy channel bins as a list. If keyword is not set, the default is [0,3,6,9].
       new_config:         Specify a new on-board phase delay correction if it has changed since the previous entry
                           in the calibration file. Do not set this keyword if the on-board correction is unchanged.
                           Must be specified in degrees.
       pick_times:         Set this keyword to manually select a timeframe within the data to perform fits on while
                           running code. If this keyword is not set, the code will use the time interval specified
                           in the "oldtimes" variable. It is recommended to pick an interval around 1 minute in length.
       overwrite_attitude: Set this keyword to indicate a manual override of the attitude data from elf_load_state.
                           The correct attitude must be defined as "correct_att" in the code (GEI) along with its uncertainity (deg).
                           Note: with the new attitude solution generation method, this is likely not needed anymore.
       reprocess:          Set this keyword to run the code in "reprocess" mode only. In this case, medians are computed
                           for any NaNs in previous completed intervals, but no fits are done on the current time selection.
                           To use this mode, the user must run the code on a time interval that falls in the 7-day interval
                           that is next recorded after the interval to reprocess.
       Isolu:              specify a start of inital guess of dSectr2add
                           (default) Isolu=0, initial guess of dSectr2add is [-4,-2,0,2,4]
                           Isolu=1, initial guess of dSectr2add is [-2,0,2,4]
       onlypng:            (default) onlypng=0, pop-up window and save png
                           onlypng=1, only save png
       outputplot:        (default) outputplot=0 save summary plot for all fits (summary_IsoluX_ItersX)
                           outputplot=1 save summary plot for all fits (summary_IsoluX_ItersX) and plots for each iteration (IsoluX_ItersX_XXX)

     EXAMPLES:
       elf_phase_delay, probe='b', Echannels=[3,6,9,12], /pick_times

     NOTES:
       This code only operates on data on or after 2019-04-30 (due to improper MSP configurations prior to
       this time).

       When running this code for the first time on a new science collection interval, the pick_times keyword must be
       turned on in order to manually select a smaller interval to perform the fits on. After selection, the
       user can store these times in the "oldtimes" variable if future runs on the same science collection are
       desired. It is recommended to pick a time interval that does not exceed two minutes in length to keep
       the code running efficiently. The optimal time interval length is around 40-60 seconds.

       After the code determines the correct phase delay, it will first ask if you want to flag it as "bad".
       A result should be flagged as "bad" if the quality of the data prohibits accurate fits to the
       pitch angle distribution. It is advised that the user views the final plot showing fits to the PAD
       for each spin period to determine if a "bad" flag is necessary. Type "y"+Enter to flag the result as
       "bad", or anything else + Enter to not flag.

       The code will then display the chi squared value of the final fits and ask the user if they want to
       record the phase delay corresponding to these fits in the phase delay file, or instead record a
       placeholder value (a median of all the previously computed phase delays with the same on-board
       correction and spin period within 20% of the current spin period of interest). Type "y"+Enter to record
       the computed phase delay, or "n"+Enter to record a placeholder value. Note that if a placeholder is used,
       the user should also flag this result as "bad".

       Lastly, the code will ask if the user would like to add these results to the phase delay file. Type "y"
       +Enter to do so, or "n"+ Enter to refrain from adding this new line to the file. In the latter case,
       the file will simply be re-written with all the pre-existing results after median-reprocessing, if
       applicable.

       Any new entry added to the phase delay file will have NaN values in place of the median sector and
       median phase angle. One must run the code on any time within the NEXT pre-defined 7-day interval (beginning from
       2019-04-30) with EPD data that follows this science collection in order to automatically compute a
       median fit value that is then re-processed into the file. The median calculation for each 7-day interval
       disregards any entries with badFlag=1, and divides the interval into smaller chunks corresponding to the
       same on-board correction and similar spin period if a change is detected.

       Note that dPhAng2add more than +/- 11 does not work. Additional sectors are added at this point.

    +
     :Description:
        Describe the procedure.

     :Keywords:
        pick_times
        new_config
        probe
        Echannels
        overwrite_attitude
        check_nonmonotonic
        sstart
        send
        soldtimes

     :Last edited: Jiashu Wu

(See projects/elfin/phase_delay/elf_phase_delay_AUTO_save.pro)