pro spinmodel_post_process,sname=sname,filetype=filetype,datatype=datatype,$
suffix=suffix,coord=coord,level=level,verbose=verbose,$
progobj=progobj,midfix=midfix,_extra=_extra
common spinmodel_common, tha_std_obj, thb_std_obj, thc_std_obj,$
thd_std_obj, the_std_obj, thf_std_obj,$
tha_ecl_obj, thb_ecl_obj, thc_ecl_obj,$
thd_ecl_obj, the_ecl_obj, thf_ecl_obj,$
tha_full_obj, thb_full_obj, thc_full_obj,$
thd_full_obj, the_full_obj, thf_full_obj, init_flag
ename = ['INVAL_PROBE', 'NO_TVAR', 'ZERO_SPINPER', 'OBJ_INVALID']
efmt = ['Unrecognized sname value: %s', $
'spinmodel_post_process: tplot variable not found: %s, This indicates that State Support Data is unavailable, unloaded, or incorrect.', $
'spinper[0] = 0 for probe %s, probably due to empty tplot variable.',$
'The standard spinmodel object for probe %s could not be constructed, probably due to a missing tplot variable.']
DEFINE_MSGBLK, 'SPINMODEL_POST_PROCESS', PREFIX='THM_SPINMODEL_POST_PROCESS_', $
ename, efmt, /ignore_duplicate
if n_elements(init_flag) EQ 0 then begin
tha_std_obj=obj_new()
thb_std_obj=obj_new()
thc_std_obj=obj_new()
thd_std_obj=obj_new()
the_std_obj=obj_new()
thf_std_obj=obj_new()
tha_ecl_obj=obj_new()
thb_ecl_obj=obj_new()
thc_ecl_obj=obj_new()
thd_ecl_obj=obj_new()
the_ecl_obj=obj_new()
thf_ecl_obj=obj_new()
tha_full_obj=obj_new()
thb_full_obj=obj_new()
thc_full_obj=obj_new()
thd_full_obj=obj_new()
the_full_obj=obj_new()
thf_full_obj=obj_new()
endif
init_flag=1
dprint,'Constructing standard spinmodel object for probe ' + sname + '.'
std_obj = obj_new('thm_spinmodel',probe=sname,midfix=midfix,suffix=suffix,eclipse=0)
if ~obj_valid(std_obj) then begin
message, name='thm_spinmodel_post_process_obj_invalid', block='spinmodel_post_process', $
sname
endif
dprint,'Constructing partially corrected eclipse spinmodel object for probe ' + sname + '.'
ecl_obj = obj_new('thm_spinmodel',probe=sname,midfix=midfix,suffix=suffix,eclipse=1)
if ~obj_valid(ecl_obj) then begin
dprint, 'An eclipse spin model could not be produced for probe '+sname+ '. This is a non-fatal error...the standard spin model will be used instead.'
ecl_obj = obj_new('thm_spinmodel',probe=sname,midfix=midfix,suffix=suffix,eclipse=0)
endif
dprint,'Constructing fully corrected eclipse spinmodel object for probe ' + sname + '.'
full_obj = obj_new('thm_spinmodel',probe=sname,midfix=midfix,suffix=suffix,eclipse=2)
if ~obj_valid(full_obj) then begin
dprint, 'A fully corrected eclipse spin model could not be produced for probe '+sname+ '. This is a non-fatal error...falling back to partial or standard model.'
full_obj = obj_new('thm_spinmodel',probe=sname,midfix=midfix,suffix=suffix,eclipse=1)
if ~obj_valid(full_obj) then begin
full_obj = obj_new('thm_spinmodel',probe=sname,midfix=midfix,suffix=suffix,eclipse=0)
endif
endif
case sname of
'a': begin
obj_destroy,tha_std_obj
tha_std_obj=std_obj
obj_destroy,tha_ecl_obj
tha_ecl_obj=ecl_obj
obj_destroy,tha_full_obj
tha_full_obj=full_obj
end
'b': begin
obj_destroy,thb_std_obj
thb_std_obj=std_obj
obj_destroy,thb_ecl_obj
thb_ecl_obj=ecl_obj
obj_destroy,thb_full_obj
thb_full_obj=full_obj
end
'c': begin
obj_destroy,thc_std_obj
thc_std_obj=std_obj
obj_destroy,thc_ecl_obj
thc_ecl_obj=ecl_obj
obj_destroy,thc_full_obj
thc_full_obj=full_obj
end
'd': begin
obj_destroy,thd_std_obj
thd_std_obj=std_obj
obj_destroy,thd_ecl_obj
thd_ecl_obj=ecl_obj
obj_destroy,thd_full_obj
thd_full_obj=full_obj
end
'e': begin
obj_destroy,the_std_obj
the_std_obj=std_obj
obj_destroy,the_ecl_obj
the_ecl_obj=ecl_obj
obj_destroy,the_full_obj
the_full_obj=full_obj
end
'f': begin
obj_destroy,thf_std_obj
thf_std_obj=std_obj
obj_destroy,thf_ecl_obj
thf_ecl_obj=ecl_obj
obj_destroy,thf_full_obj
thf_full_obj=full_obj
end
endcase
end