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