Blame view

src/idl/dustem_add_inst.pro 1.06 KB
52a3cc37   Annie Hughes   First commit of I...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
FUNCTION DUSTEM_ADD_INST, sf, tag, nsz, ntrans=ntrans
; fills in data for existing instruments in SMDAT structure 
; or add a new instrument to SMDAT structure 
;
; SF     (I): SMDAT input structure
; TAG    (I): name of instrument to add in
; NSZ    (I): array(2) of sizes [nr of data pts, nr of grain types] 
; NTRANS (I): nr of points for transmission (bad flux data)

  stag = TAG_NAMES(sf)
  ntag = N_TAGS(sf)
  tag = STRUPCASE('I_'+STRTRIM(tag,2))
  itg = WHERE( stag EQ tag, ctg )
  if n_elements(nsz) EQ 2 then begin
     nx = nsz(0) & ntype = nsz(1)
  endif else begin
     print,'(F) DUSTEM_ADD_INST: array of sizes must be 2D'
  endelse
  if ctg EQ 0 then begin
     if n_elements(ntrans) EQ 0 then st = CREATE_STRUCT( tag, DUSTEM_STR_INST(nx,n2=ntype) ) $
     else st = CREATE_STRUCT( tag, DUSTEM_STR_INST(nx,n2=ntype,n3=ntrans) )
     sf = CREATE_STRUCT( sf, st )     
     stag = TAG_NAMES(sf)
     itg = WHERE( stag EQ tag )
     sf.(itg).isel = intarr(nx) + 1
  endif else begin
     print,'(F) DUSTEM_ADD_INST: INST already exists in structure'
  endelse
  return,sf
END