dustem_test_model_exists.pro 3.76 KB
function dustem_test_model_exists,model $ 
                                  ,help=help $
                                  ,polarisation=polarisation $
                                  ,silent=silent

;+
; NAME:
;    dustem_test_model_exists
;
; PURPOSE:
;    Test if DustEMWrap user has entered a string that matches a known dust model
;  
; CATEGORY:
;    DustEMWrap, Distributed, Low-Level, helper parse I/O
;
; CALLING SEQUENCE:
;    exist_status=dustem_test_model_exists(model)
;  
; INPUTS:
;    model : string provided by user to indicate an ISM dust model
;
; OPTIONAL INPUT PARAMETERS:
;    None
;
; OUTPUTS:
;    exist_status : 1 = exists, 0 = does not exists
;
; OPTIONAL OUTPUT PARAMETERS:
;
; ACCEPTED KEY-WORDS:
;    help = print this help
;    silent = determine status, but don't print anything
;    polarisation =  check if model includes polarisation
;  
; COMMON BLOCKS:
;    None
;
; SIDE EFFECTS:
;    If model is unknown, code will stop.
;
; RESTRICTIONS:
;    The DustEMWrap IDL code must be installed
;
; PROCEDURES AND SUBROUTINES USED:
;
; EXAMPLES
;   dustem_test_model_exists,'DL01'
;   dustem_test_model_exists,'G17_MODELA',/pol,/silent
;  
; MODIFICATION HISTORY:
;    Written by AH Feb 2023
;    Evolution details on the DustEMWrap gitlab.
;    See http://dustemwrap.irap.omp.eu/ for FAQ and help.  
;-

  exists=0

  IF keyword_set(help) or not keyword_set(model) THEN BEGIN
     doc_library,'dustem_test_model_exists'
     goto,the_end
  END

  known_mdls=['MC10' $
              ,'COMPIEGNE_ETAL10' $ ; for backwards compatibility
              ,'DBP90' $
              ,'DL01' $ ; for backwards compatibility
              ,'LD01' $ ; for backwards compatibility
              ,'DL01_RV3P1_BC6' $
;              ,'DL01_RV5P5B_BC3' $ ; removed from DUSTEM fortran in Feb2023 release
;              ,'DL01_RV5P5B_BC0' $ ; removed from DUSTEM fortran in Feb2023 release
              ,'WD01' $ ; for convenience
              ,'WD01_RV5P5B' $ 
              ,'DL07' $
              ,'J13' $
              ,'AJ13' $ ; for backwards compatibility
              ,'G17_MODELA' $
              ,'G17_MODELB' $
              ,'G17_MODELC' $
              ,'G17_MODELD' $
              ,'THEMIS' $ ; for convenience
              ,'THEMIS2' $ ; for convenience
              ,'Y24' $
;              ,'ASTRODUST' $ ; removed from DUSTEM fortran in Feb2023 release
;              ,'NY_MODELA' $ ; removed from DUSTEM fortran in Feb2023 release
              ,'USER_MODEL']

  test_model = where(known_mdls eq model,ct)

  if ct eq 0 then begin
     if not keyword_set(silent) then begin
        message,'-----------------------------',/continue
        message,'ISM dust model '+model+' unknown',/continue
        message,'Known models are ',/continue
        for i=0,n_elements(known_mdls)-1 do print,known_mdls[i]
        message,'-----------------------------',/continue
     end
     exists=0
  end else begin
     exists=1
  end
  

  pol_mdls=['G17_MODELA' $
              ,'G17_MODELB' $
              ,'G17_MODELC' $
              ,'G17_MODELD' $
              ,'Y24' $
              ,'THEMIS' $
              ,'THEMIS2' $
              ,'USER_MODEL'] ; we assume the USER knows their own model!

  if keyword_set(polarisation) then begin
     test_model = where(pol_mdls eq model,ct)
     if ct eq 0 then begin
        if not keyword_set(silent) then begin
           message,'-----------------------------',/continue
           message,'ISM dust model '+model+' does not describe polarisation',/continue
           message,'Known polarisation models are ',/continue
           for i=0,n_elements(pol_mdls)-1 do print,pol_mdls[i]
           message,'-----------------------------',/continue
        end
        exists=0
     end else begin
        exists=1
     end
     
  endif

  the_end:
  return,exists
end