This page was created by the IDL library routine mk_html_help2.

Last modified: Wed Jun 24 12:41:17 2009.


Directory Listing of Routines


Routine Descriptions

SEGMENT_TEST.PRO

[Next Routine] [List of Routines]
 NAME:
    SEGMENT_TEST.PRO

 PURPOSE:
    Check a spinmodel segment structure to ensure that the model parameters
    b and c are consistent with the start and end times and
    spin counts

 CATEGORY:
   TDAS

 CALLING SEQUENCE:
   segment_test,probe,segment,result

  INPUTS:
    probe: A single character probe letter (only used in output messages).
    segment: A spinmodel_segment structure.

  OUTPUTS:
    result: 0 for failure, 1 for success

  KEYWORDS:
    None.

  PROCEDURE:
    Calls segment_interp_t to get spin count and spin phase at
       segment start/end times.
    Calls segment_interp_n to get sun pulse times of segment
       start/end counts.
    Cross check results of segment_interp_t and segment_interp_n,
       verifying that interp_t and interp_n results are consistent
       within modest tolerances (100 usec for times, 0.1 deg for
       phase angles).
    Check maxgap field against 4-hour threshold; large gaps are
       likely a result of missing data.

  EXAMPLE:
    mptr=spinmodel_get_ptr('a')
    sptr=(*mptr).segs_ptr
    segment_test,'a',(*sptr)[0],result

Written by: Jim Lewis (jwl@ssl.berkeley.edu)
Change Date: 2007-10-08

(See themis/spin/segment_test.pro)


SPINMODEL_GET_PTR.PRO

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
    SPINMODEL_GET_PTR.PRO

 PURPOSE:  
   Returns a pointer to the spin model, specified by a single
   letter probe designation ('a' through 'f').  This is to avoid
   having to define the spinmodel common block all over the place.

 CATEGORY: 
   TDAS

 CALLING SEQUENCE:
   model_ptr=spinmodel_get_ptr('a')

  INPUTS:
    probe: A scalar character, one of 'a' through 'f', specifying which model
       pointer to return.

  OUTPUTS:
    model_ptr: The return value is a pointer to the specified spin model,
       suitable for passing to the other spinmodel manipulation routines.

  KEYWORDS:
    None.
    
  PROCEDURE:
    Test probe argument for validity; return appropriate value from
    the spinmodel_common block.

  EXAMPLE:
     model_ptr=spinmodel_get_ptr('a')
     spinmodel_test,model_ptr

Written by: Jim Lewis (jwl@ssl.berkeley.edu)
Change Date: 2007-10-08

(See themis/spin/spinmodel_get_ptr.pro)


SPINMODEL_INTERP_N.PRO

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
    SPINMODEL_INTERP_N.PRO

 PURPOSE:
    Given a spin model and spin count  (or array of counts), calculate
    the sun pulse time and spin period at each input count.

 CATEGORY:
   TDAS

 CALLING SEQUENCE:
   spinmodel_interp_n,model=modelptr,count=input_counts,$
      time=output_times, spinper=output_spinper

  INPUTS:
    Model: pointer to a spinmodel structure
    Count: A long integer (or long integer array) specifying the spin
      count to use.  If the input is a scalar, all outputs
      will be scalars; otherwise, all outputs are arrays having
      the same size as the input counts.

  OUTPUTS:
    spinper: Optional keyword parameter to receive spin period values.
    time: Optional keyword parameter to receive sun pulse time
       of each input count.

  KEYWORDS:

  /MODEL: Required input keyword argument, specifying a pointer to a 
      spinmodel structure.
  /COUNT: Required input keyword argument specifying a time or array of times.
  /SPINPER: Optional keyword argument to receive spin period values.
  /TIME:  Optional keyword argument to receive sun pulse times.

  PROCEDURE:
     Find the spinmodel segment containing the input spin count.
     Invert phi(t) function to find time corresponding to this count.
     Use b and c segment parameters to determine the spin period
       at the sunpulse time.
  
  EXAMPLE:
  ; Retrieve first 100 sun pulse times included in model for THA:
  modelptr=spinmodel_get_ptr('a')
  spinmodel_interp_n,model=modelptr,count=lindgen(100),time=output_times
  

(See themis/spin/spinmodel_interp_n.pro)


SPINMODEL_INTERP_T.PRO

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
    SPINMODEL_INTERP_T.PRO

 PURPOSE:
    Given a spin model and time (or array of times), calculate
    the spin count, spin phase, spin period, and time of last sun pulse
    for each input time.

 CATEGORY:
   TDAS

 CALLING SEQUENCE:
   spinmodel_interp_t,model=modelptr,time=input_times,$
      spincount=output_spincount, spinper=output_spinper,$
      t_last=output_sun_pulse_times

  INPUTS:
    Model: pointer to s spinmodel structure
    Time: A double precision scalar or array specifying the input times.
      If the input is a scalar, all outputs will be scalars; otherwise, 
      all outputs are arrays having the same size as the input times.

  OUTPUTS:
    spinper: Optional keyword parameter to receive spin period values.
    tlast: Optional keyword parameter to receive sun pulse time
       immediately preceding each input time.
    spincount: Optional keyword parameter to receive count of spins
       since the start of the model.
    spinphase: Optional keyword parameter to receive the spin phase
       (ranging from 0.0 to 360.0 degrees) at each input time.

  KEYWORDS:

  /MODEL: Required input keyword argument, specifying a pointer to a 
      spinmodel structure.
  /TIME: Required input keyword argument specifying a time or array of times.
  /SPINPER: Optional keyword argument to receive spin period values.
  /T_LAST:  Optional keyword argument to receive sun pulse times
  /SPINCOUNT:  Optional keyword argument to receive spin counts
  /SPINPHASE:  Optional keyword argument to receive spin phase

  PROCEDURE:
     Find the spinmodel segment containing the input time.
     Use b and c segment parameters to determine the spin period,
       spin phase, and spin count at each input time
     Invert phi(t) function to find sun pulse time immediately preceding
       each input time.
  
  EXAMPLE:

  ; Assume 'input_times' and 'input_spinphase' already exist as a 
  ; IDL variables -- perhaps obtained from thm_load_state.
  ;
  ; Get a pointer to the spin model for probe A
  modelptr=spinmodel_get_ptr('a')
   
  ; Calculate spin phase at each time from spin model
 
  spinmodel_interp_t,model=modelptr,time=input_times,spinphase=output_spinphase

  ; Calculate spinphase differences between spin model and state 
  phi_diff=output_spinphase-input_spinphase
  
  ; Fix wraparounds

  i=where(phi_diff GT 180.0D)
  i2=where(phi_diff LT -180.0D)
  phi_diff[i] = phi_diff[i] - 360.0D
  phi_diff[i2] = phi_diff[i2] + 360.0D

  Plot results

  plot,input_times,phi_diff
  

(See themis/spin/spinmodel_interp_t.pro)


SPINMODEL_TEST.PRO

[Previous Routine] [Next Routine] [List of Routines]
 NAME:
    SPINMODEL_TEST.PRO

 PURPOSE:
   Perform consistency checks on a spin model.

 CATEGORY:
   TDAS

 CALLING SEQUENCE:
   spinmodel_test,model_ptr

  INPUTS:
    model_ptr: A pointer to a spinmodel structure, obtained from the 
    spinmodel_common block or the spinmodel_get_ptr() function.
    This input must be a scalar.

  OUTPUTS:
    Prints "PASS"/"FAIL" messages depending on outcome of tests.

  KEYWORDS:
    None.

  PROCEDURE:
    Validate model_ptr input argument.
    Compare spin model capacity to actual number of segments.
    Validate pointer to model segments.
    Call segment_test on each model segment, check for any failures.
    Examine boundaries of adjacent segments, making sure time and
       spin_number endpoints are identical across each pair.
    Exercise spinmodel_interp_n by retrieving modeled sun pulse
       times by spin number.
    Exercise spinmodel_interp_t by recalculating the spin count
       and spin phase at each modeled sun pulse time.
    Cross check results of spinmodel_interp_n and spinmodel_interp_t
       to verify that the expected values are produced within
       modest tolerances (allowable phase error .01 deg at each
       modeled sun pulse time).

    

  EXAMPLE:
     model_ptr=spinmodel_get_ptr('a')
     spinmodel_test,model_ptr

Written by: Jim Lewis (jwl@ssl.berkeley.edu)
Change Date: 2007-10-08

(See themis/spin/spinmodel_test.pro)


THM_LOAD_SPIN

[Previous Routine] [List of Routines]
Procedure: THM_LOAD_SPIN

Purpose:  Loads THEMIS spin model parameters, performs some post-processing
 of data loaded from the SPIN CDFs, and stashes the resulting spin model
 in a common block.

keywords:
  probe = Probe name. The default is 'all', i.e., load all available probes.
          This can be an array of strings, e.g., ['a', 'b'] or a
          single string delimited by spaces, e.g., 'a b'
          Flatsat data (probe 'f') is not returned unless explicitly
          mentioned.
  datatype = The type of data to be loaded, can be an array of strings 
          or single string separate by spaces.  The default is 'all'
  TRANGE= (Optional) Time range of interest  (2 element array), if
          this is not set, the default is to prompt the user. Note
          that if the input time range is not a full day, a full
          day's data is loaded
  level = the level of the data, the default is 'l1', or level-1
          data. A string (e.g., 'l2') or an integer can be used. 'all'
          can be passed in also, to get all levels.
  CDF_DATA: named variable in which to return cdf data structure: only works
          for a single spacecraft and datafile name.
  VARNAMES: names of variables to load from cdf: default is all.
  /GET_SUPPORT_DATA: load support_data variables as well as data variables 
                      into tplot variables.
  /DOWNLOADONLY: download file but don't read it.
  /valid_names, if set, then this routine will return the valid probe, datatype
          and/or level options in named variables supplied as 
          arguments to the corresponding keywords.
  files   named varible for output of pathnames of local files.
  /VERBOSE  set to output some useful info
Example:
   thm_load_spin,probe=['a','b'] 

Written by: Jim Lewis (jwl@ssl.berkeley.edu)
Change Date: 2007-10-08

(See themis/spin/thm_load_spin.pro)