%-------------------------------------------------------- % file: ~dd/isis/v0.97/start.i % % 1/16/2001 - dd % % This file contains a bunch of startup things for ISIS... % For versions: 0.9.7, 0.9.8, 0.9.8p1, % % Needs file(s): % capella_manyT.model -- nominal model to asses relative line emis's. %-------------------------------------------------------- %------------------setup kind of things--------------------- % chatty debug? _debug_info = 1; %------------------setup kind of things--------------------- % list "recent" files: define recent (){ system ("ls -lst1 | head -15"); } %------------------------ useful constants ------------------- % the guy thinks in energy... variable hc = 12.3985; % grating periods: these are useful for scaling the LRF - expect the % LRF for each grating to have similar FWHM, etc. when given % in millimeters. The wavelength equivalent then scales as the period. variable p_leg, p_meg, p_heg; p_leg = 9912.16; p_meg = 4001.41; p_heg = 2000.81; % Where is the CXC CALDB? variable CALDB = "/nfs/wiwaxia/d4/ASC/data/caldb"; % %------------------------ function-return variables ------------------- % define output variable for the region_flux/counts functions variable rsout; % for conf() output: variable conflo, confhi; % for get_data[_counts/flux]() output: % gdmodel is for model, gdsel is for selection: gdsel = where(...) variable gds, gdmodel, gdsel; % for get_arf() output variable gas; % for fit() return values variable firet = struct {statistic, num_variable_params, num_bins}; %%%variable fchisqr, fnpars, fnbins; %------------------------ new useful functions ------------------- % % Not needed: it's included in distribution. % group_data.i from my own code: %%()=evalfile("group_data.i"); % Getting arrays from a structure... % Thanks John D! define array_struct_field (s, f) { if (typeof (s) == Struct_Type) return get_struct_field (s, f); variable type = typeof (get_struct_field (s[0], f)); return array_map (type, &get_struct_field, s, f); } %------------------------plot colors------------------- % Define the PG colors % In addition to the colors defined in the isisrc file: % variable black = 0; % "0" is the same as 16 = black variable na_clr9 = 9; % looks same as green variable na_clr10 =10; % looks same as green variable mediblue =11; % isisrc: not defined variable purpblue =12; % isisrc: not defined variable pinkish =13; % isisrc: not defined, not very distinct? variable na_clr14 =14; % too dark a grey for a black background %--------------------data set setup ---------------- % Setup named variables for the data set name, directory, % and number of spectra variable data_set_name; data_set_name="ISIS Data"; variable data_dir; data_dir="."; variable data_n_spectra, data_nh; data_n_spectra = 4; data_nh=0.0; % % special variable for data grouping, e.g. used for fil analysis % where LRF is broader... variable fil_group; % default value fil_group=1; % Generally, from HETG, four spectra are relevant from an % observation: those formed by the + and - first orders of % the MEG and HEG gratings: % map some names to histogram's indices in the set variable megm, megp, hegm, hegp; % default is for cannonical set of four HETG spectra: megm=1; megp=2; hegm=3; hegp=4; % and their colors... variable cmegm, cmegp, chegm, chegp; cmegm=yellow; cmegp=red; chegm=green; chegp=ltblue; % color to indicate ignored data variable cignore; cignore = grey; %-------------------------------------------------------- % Database and model kinds of things %---------------------- Database Setup --------------------------- % Read in the databases variable db_name; % Read it all in... Use_Memory=1; % Select a database for lines: if (1 > 0) { % Temp-Density data base: db_name="apec_d"; % Use temp 10^5 to 10^8 % and density in O Ne range: 10^9 to 10^13 atoms(apec_d); plasma(apec_d, [0.9e9,1.1e13], [0.9e5,1.1e8]); } else { % No-density data base: db_name = "aped"; %Read in the atoms first atoms(aped); plasma(aped); } message(""); message(" Using "+db_name+" database. "); message(""); %---------------------- Nominal Model Setup --------------------------- % Set a nominal emmision model with 3 temps covering wide range... % Include absorbtion: % % edit_model; % %# id Temp Dens Abund Norm Vturb redshift Nh %# (K) (cm^-3) (km/s) (cm^-2) % 1 6.3000e+06 1.0000e+12 1.0000e+00 8.0000e+45 0.0 0.0000e+00 1.0000e+21 % 2 3.0000e+06 1.0000e+12 1.0000e+00 1.0000e+45 0.0 0.0000e+00 1.0000e+21 % 3 3.0000e+07 1.0000e+12 1.0000e+00 1.0000e+45 1000.0 0.0000e+00 1.0000e+21 % % Representative assortment of 3 Ts load_model("nominal_manyTwabs.model"); % or could use: %%load_model("capella_manyT.model"); variable mod_minlam, mod_maxlam, mod_binlo, mod_binhi, mod_em; mod_minlam = 1.0; mod_maxlam = 26.0; % define it on 0.01 A bins (mod_binlo, mod_binhi) = linear_grid(mod_minlam , mod_maxlam, (mod_maxlam-mod_minlam)*100); %%use_thermal_profile; use_delta_profile; mod_em = model_spectrum(mod_binlo, mod_binhi); %------------------------plot windows------------------- % Setup two nominal windows for plotting % Use psplot to flag ps output... variable p1,p4,vps,psplot; % Open them, with different sizes p1 = open_plot("/xwin"); resize(25,0.6); % single pane, landscape p4 = open_plot("/xwin",2,2); resize(25,0.6); % 4 panes, "landscape" % Set color to indicate different curves... window(p1); line_or_color(1); color(white); window(p4); line_or_color(1); color(white); % vps and psplot are for Postscript plot option: psplot = 0; %% if (psplot = 1) { %%vps = open_plot("fit.ps/vcps", 1, 2); %%window(vps); } %%pane(1); %% plot... %% if (psplot = 1) { %% close_plot(vps); %% } %-------------------------------------------------------- % Setup some variables and windows for fitting plots % from v0.8/fit_setup.i % % do these things once: % add a window variable winFit; winFit = open_plot("/xwin", 1, 2); resize(16,1.4); % define some variables used by fitting routines (e.g., fit_line.isis) variable lamcent, lamrange, lamlow, lamhigh, corelow, corehigh; variable approx_flux, appwingcounts, corefwhm, wingcont; variable wingstart, xmodel, ymodel; variable fdata, cfdata, ftitle, cmodel; % default values: fdata = megm; cfdata = cmegm; variable fperiod, range_scale; variable part_order_string; % default is bin_integral plotting plot_bin_integral; % color for the model cmodel = purple; %---------------------- Nominal Groups Setup --------------------------- % Setup groups that I'm interested in % Define groups variable N_all, O_all, Ne_all, Mg_all, Si_all, S_all, Ar_all, Ca_all, Fe_all; variable Fe_16, Fe_17, Fe_18, Fe_19; variable Fe_22, Fe_23, Fe_24, Fe_25, Fe_26; % and their colors (hey, the guy is picky!) variable cN_all, cO_all, cNe_all, cMg_all, cSi_all, cS_all, cFe_all; variable cAr_all, cCa_all; variable cFe_16, cFe_17, cFe_18, cFe_19; variable cFe_22, cFe_23, cFe_24, cFe_25, cFe_26; cN_all=grey; cO_all=pinkish; cNe_all=yellow; cMg_all=green; cSi_all=white; cS_all = purple; cAr_all=orange; cCa_all=yellow; cFe_all=blue; cFe_16=purple; cFe_17=ltblue; cFe_18=mediblue, cFe_19 = purpblue; cFe_22=purple; cFe_23=ltblue; cFe_24=mediblue, cFe_25 = purpblue; cFe_26=purple; % and a plot group style structure and redshift variable spg, lil_spg, clil; spg = line_label_default_style(); spg.char_height = 1.0; spg.offset = 0.25; spg.top_frac = 0.8; spg.bottom_frac = 0.75; spg.angle = 90.0; spg.justify = 0.0; % style to mark "lines I like" : lil_spg = line_label_default_style(); lil_spg.char_height = 0.001; lil_spg.offset = 0.0; lil_spg.top_frac = 0.97; lil_spg.bottom_frac = 0.93; lil_spg.angle = 90.0; lil_spg.justify = 0.0; clil = ltblue; % % redshift for the plot_group calls: variable zpg; zpg=0.0; % Fill them % limit to HETGS wavelength range N_all = brightest(10, where( el_ion(N) and wl(1.,35.) )); O_all = brightest(12, where( el_ion(O) and wl(1.,35.) )); Mg_all = brightest(12, where( el_ion(Mg) and wl(1.,35.) )); Ne_all = brightest(10, where( el_ion(Ne) and wl(1.,35.) )); % Show these only in the short wavelength end Si_all = brightest(5, where( el_ion(Si) and wl(1.,10.) )); S_all = brightest(5, where( el_ion(S) and wl(1.,10.) )); Ca_all = brightest(5, where( el_ion(Ca) and wl(1.,10.) )); Ar_all = brightest(5, where( el_ion(Ar) and wl(1.,10.) )); % Fe_all = brightest(50, where( el_ion(Fe) and wl(1.,25.) )); % Fe_16 = brightest(5, where( el_ion(Fe, 16) and wl(1.,25.) )); Fe_17 = brightest(7, where( el_ion(Fe, 17) and wl(1.,25.) )); Fe_18 = brightest(10, where( el_ion(Fe, 18) and wl(1.,25.) )); Fe_19 = brightest(5, where( el_ion(Fe, 19) and wl(1.,25.) )); % show the ~6 keV lines of these... Fe_22 = brightest(2, where( el_ion(Fe, 22) and wl(1.,3.) )); Fe_23 = brightest(2, where( el_ion(Fe, 23) and wl(1.,3.) )); Fe_24 = brightest(2, where( el_ion(Fe, 24) and wl(1.,3.) )); Fe_25 = brightest(2, where( el_ion(Fe, 25) and wl(1.,3.) )); Fe_26 = brightest(2, where( el_ion(Fe, 26) and wl(1.,3.) )); % Also define specific lines that I like: % This is copied from lines_i_like.i : %-------------------------------------------------------- % file: lines_i_like.i % % Fill "line-index" variables for specific lines in the % database. Note that multiple indices may be assigned, % e.g., for Lyman Alpha lines. % variable lilam, lidl; % +/- acceptance range: lidl = 0.010; % Nitrogen variable li_NLyAlpha; variable g_NLyAlpha=70701; lilam = 24.7794; li_NLyAlpha = where( el_ion(N,N) and wl(lilam-lidl,lilam+lidl) ); define_group(g_NLyAlpha, li_NLyAlpha); % Oxygen variable li_OLyAlpha, li_OLyBeta, li_OHeTripR, li_OHeTripI, li_OHeTripF; variable g_OLyAlpha=80801; variable g_OLyBeta=80802; variable g_OHeTripR=80701; variable g_OHeTripI=80702; variable g_OHeTripF=80703; lilam = 18.9672; li_OLyAlpha = where( el_ion(O,O) and wl(lilam-lidl,lilam+lidl) ); define_group(g_OLyAlpha, li_OLyAlpha); lilam = 16.0056; li_OLyBeta = where( el_ion(O,O) and wl(lilam-lidl,lilam+lidl) ); define_group(g_OLyBeta, li_OLyBeta); lilam = 21.6015; li_OHeTripR = where( el_ion(O,O-1) and wl(lilam-lidl,lilam+lidl) ); define_group(g_OHeTripR, li_OHeTripR); lilam = 21.8036; li_OHeTripI = where( el_ion(O,O-1) and wl(lilam-lidl,lilam+lidl) ); define_group(g_OHeTripI, li_OHeTripI); lilam = 22.0977; li_OHeTripF = where( el_ion(O,O-1) and wl(lilam-lidl,lilam+lidl) ); define_group(g_OHeTripF, li_OHeTripF); % Oxygen VII variable li_OVII_18p6A; variable g_OVII_18p6A=80718; lilam = 18.6270; li_OVII_18p6A = where( el_ion(O,7) and wl(lilam-lidl,lilam+lidl) ); define_group(g_OVII_18p6A, li_OVII_18p6A); % Neon variable li_NeLyAlpha, li_NeLyBeta, li_NeHeTripR, li_NeHeTripI, li_NeHeTripF; variable li_NeIX_11p5A; variable li_NeX_9p7A; variable g_NeLyAlpha=101001; variable g_NeLyBeta=101002; variable g_NeHeTripR=100901; variable g_NeHeTripI=100902; variable g_NeHeTripF=100903; variable g_NeIX_11p5A=100911; variable g_NeX_9p7A=101009; lilam = 12.1322; li_NeLyAlpha = where( el_ion(Ne,Ne) and wl(lilam-lidl,lilam+lidl) ); define_group(g_NeLyAlpha, li_NeLyAlpha); lilam = 10.2386; li_NeLyBeta = where( el_ion(Ne,Ne) and wl(lilam-lidl,lilam+lidl) ); define_group(g_NeLyBeta, li_NeLyBeta); lilam = 13.4473; li_NeHeTripR = where( el_ion(Ne,Ne-1) and wl(lilam-lidl,lilam+lidl) ); define_group(g_NeHeTripR, li_NeHeTripR); lilam = 13.5531; li_NeHeTripI = where( el_ion(Ne,Ne-1) and wl(lilam-lidl,lilam+lidl) ); define_group(g_NeHeTripI, li_NeHeTripI); lilam = 13.6990; li_NeHeTripF = where( el_ion(Ne,Ne-1) and wl(lilam-lidl,lilam+lidl) ); define_group(g_NeHeTripF, li_NeHeTripF); lilam = 11.56; li_NeIX_11p5A = where( el_ion(Ne,Ne-1) and wl(lilam-lidl,lilam+lidl) ); define_group(g_NeIX_11p5A, li_NeIX_11p5A); lilam = 9.7081; li_NeX_9p7A = where( el_ion(Ne,Ne) and wl(lilam-lidl,lilam+lidl) ); define_group(g_NeX_9p7A, li_NeX_9p7A); % Magnesium variable li_MgLyAlpha, li_MgLyBeta, li_MgXI_7p8A, li_MgHeTripR, li_MgHeTripI, li_MgHeTripF; variable g_MgLyAlpha=121201; variable g_MgLyBeta=121202; variable g_MgHeTripR=121101; variable g_MgHeTripI=121102; variable g_MgHeTripF=121103; variable g_MgXI_7p8A=121107; lilam = 8.41930; li_MgLyAlpha = where( el_ion(Mg,Mg) and wl(lilam-lidl,lilam+lidl) ); define_group(g_MgLyAlpha, li_MgLyAlpha); lilam = 7.10580; li_MgLyBeta = where( el_ion(Mg,Mg) and wl(lilam-lidl,lilam+lidl) ); define_group(g_MgLyBeta, li_MgLyBeta); lilam = 9.16875; li_MgHeTripR = where( el_ion(Mg,Mg-1) and wl(lilam-lidl,lilam+lidl) ); define_group(g_MgHeTripR, li_MgHeTripR); lilam = 9.23121; li_MgHeTripI = where( el_ion(Mg,Mg-1) and wl(lilam-lidl,lilam+lidl) ); define_group(g_MgHeTripI, li_MgHeTripI); lilam = 9.31434; li_MgHeTripF = where( el_ion(Mg,Mg-1) and wl(lilam-lidl,lilam+lidl) ); define_group(g_MgHeTripF, li_MgHeTripF); lilam = 7.8500; li_MgXI_7p8A = where( el_ion(Mg,Mg-1) and wl(lilam-lidl,lilam+lidl) ); define_group(g_MgXI_7p8A, li_MgXI_7p8A); % Silicon variable li_SiLyAlpha, li_SiHeTripR, li_SiHeTripI, li_SiHeTripF; variable g_SiLyAlpha=141401; variable g_SiHeTripR=141301; variable g_SiHeTripI=141302; variable g_SiHeTripF=141303; lilam = 6.18050; li_SiLyAlpha = where( el_ion(Si,Si) and wl(lilam-lidl,lilam+lidl) ); define_group(g_SiLyAlpha, li_SiLyAlpha); lilam = 6.64795; li_SiHeTripR = where( el_ion(Si,Si-1) and wl(lilam-lidl,lilam+lidl) ); define_group(g_SiHeTripR, li_SiHeTripR); lilam = 6.68819; li_SiHeTripI = where( el_ion(Si,Si-1) and wl(lilam-lidl,lilam+lidl) ); define_group(g_SiHeTripI, li_SiHeTripI); lilam = 6.74029; li_SiHeTripF = where( el_ion(Si,Si-1) and wl(lilam-lidl,lilam+lidl) ); define_group(g_SiHeTripF, li_SiHeTripF); % Fe XVII variable li_FeXVII_12p2A, li_FeXVII_15A, li_FeXVII_15p2A, li_FeXVII_16p7A, li_FeXVII_17A, li_FeXVII_17p1A; variable g_FeXVII_15A=261701; variable g_FeXVII_17A=261702; variable g_FeXVII_17p1A=261703; variable g_FeXVII_12p2A=261704; variable g_FeXVII_15p2A=261705; variable g_FeXVII_16p7A=261706; lilam=15.0140; li_FeXVII_15A = where( el_ion(Fe,17) and wl(lilam-lidl,lilam+lidl) ); define_group(g_FeXVII_15A, li_FeXVII_15A); lilam=17.0510; li_FeXVII_17A = where( el_ion(Fe,17) and wl(lilam-lidl,lilam+lidl) ); define_group(g_FeXVII_17A, li_FeXVII_17A); lilam=17.0960; li_FeXVII_17p1A = where( el_ion(Fe,17) and wl(lilam-lidl,lilam+lidl) ); define_group(g_FeXVII_17p1A, li_FeXVII_17p1A); %li_FeXVII_17A = brightest(2, % where( el_ion(Fe,17) and wl(lilam-0.10,lilam+0.10) ) ); lilam=12.2661; li_FeXVII_12p2A = where( el_ion(Fe,17) and wl(lilam-lidl,lilam+lidl) ); define_group(g_FeXVII_12p2A, li_FeXVII_12p2A); lilam=15.2610; li_FeXVII_15p2A = where( el_ion(Fe,17) and wl(lilam-lidl,lilam+lidl) ); define_group(g_FeXVII_15p2A, li_FeXVII_15p2A); lilam=16.7800; li_FeXVII_16p7A = where( el_ion(Fe,17) and wl(lilam-lidl,lilam+lidl) ); define_group(g_FeXVII_16p7A, li_FeXVII_16p7A); % Fe XVIII variable li_FeXVIII_14p2A, li_FeXVIII_15p6A, li_FeXVIII_16A, li_FeXVIII_17p6A; variable g_FeXVIII_14p2A = 261814; variable g_FeXVIII_15p6A = 261815; variable g_FeXVIII_16A = 261816; variable g_FeXVIII_17p6A = 261817; lilam=14.2100; li_FeXVIII_14p2A = where( el_ion(Fe,18) and wl(lilam-lidl,lilam+lidl) ); define_group(g_FeXVIII_14p2A, li_FeXVIII_14p2A); lilam=15.6230; li_FeXVIII_15p6A = where( el_ion(Fe,18) and wl(lilam-lidl,lilam+lidl) ); define_group(g_FeXVIII_15p6A, li_FeXVIII_15p6A); lilam=16.0730; li_FeXVIII_16A = where( el_ion(Fe,18) and wl(lilam-lidl,lilam+lidl) ); define_group(g_FeXVIII_16A, li_FeXVIII_16A); lilam=17.6179; li_FeXVIII_17p6A = where( el_ion(Fe,18) and wl(lilam-lidl,lilam+lidl) ); define_group(g_FeXVIII_17p6A, li_FeXVIII_17p6A); % Fe XIX variable li_FeXIX_13p5A; variable g_FeXIX_13p5A = 261913; lilam=13.5200; li_FeXIX_13p5A = where( el_ion(Fe,19) and wl(lilam-lidl,lilam+lidl) ); define_group(g_FeXIX_13p5A, li_FeXIX_13p5A); % Fe XX variable li_FeXX_12p82A, li_FeXX_12p83A, li_FeXX_12p85A; variable g_FeXX_12p82A = 262011; variable g_FeXX_12p83A = 262012; variable g_FeXX_12p85A = 262013; lilam=12.8200; li_FeXX_12p82A = where( el_ion(Fe,20) and wl(lilam-lidl,lilam+0.6*lidl) ); define_group(g_FeXX_12p82A, li_FeXX_12p82A); lilam=12.8349; li_FeXX_12p83A = where( el_ion(Fe,20) and wl(lilam-0.6*lidl,lilam+0.9*lidl) ); define_group(g_FeXX_12p83A, li_FeXX_12p83A); lilam=12.8542; li_FeXX_12p85A = where( el_ion(Fe,20) and wl(lilam-0.9*lidl,lilam+lidl) ); define_group(g_FeXX_12p85A, li_FeXX_12p85A); % Fe XXV variable li_FeLyAlpha, li_FeHeTripR, li_FeHeTripI, li_FeHeTripF; variable g_FeLyAlpha=262601; variable g_FeHeTripR=262501; variable g_FeHeTripI=262502; variable g_FeHeTripF=262503; lilam = 1.77810; li_FeLyAlpha = where( el_ion(Fe,Fe) and wl(lilam-0.002,lilam+0.004) ); define_group(g_FeLyAlpha, li_FeLyAlpha); lilam = 1.85040; li_FeHeTripR = where( el_ion(Fe,Fe-1) and wl(lilam-0.002,lilam+0.002) ); define_group(g_FeHeTripR, li_FeHeTripR); lilam = 1.85541; li_FeHeTripI = where( el_ion(Fe,Fe-1) and wl(lilam-0.002,lilam+0.002) ); define_group(g_FeHeTripI, li_FeHeTripI); lilam = 1.86819; li_FeHeTripF = where( el_ion(Fe,Fe-1) and wl(lilam-0.002,lilam+0.002) ); define_group(g_FeHeTripF, li_FeHeTripF); % All together variable lil_group = [0]; lil_group = [li_NLyAlpha, li_OLyAlpha,li_OLyBeta,li_OHeTripR,li_OHeTripI,li_OHeTripF, li_OVII_18p6A, li_NeLyAlpha,li_NeLyBeta,li_NeHeTripR,li_NeHeTripI,li_NeHeTripF, li_NeIX_11p5A, li_NeX_9p7A, li_MgLyAlpha,li_MgLyBeta,li_MgHeTripR,li_MgHeTripI,li_MgHeTripF, li_MgXI_7p8A, li_SiLyAlpha,li_SiHeTripR,li_SiHeTripI,li_SiHeTripF, li_FeXVII_12p2A, li_FeXVII_15A, li_FeXVII_15p2A, li_FeXVII_16p7A, li_FeXVII_17A, li_FeXVII_17p1A, li_FeXVIII_14p2A, li_FeXVIII_15p6A, li_FeXVIII_16A, li_FeXVIII_17p6A, li_FeXIX_13p5A, li_FeXX_12p82A, li_FeXX_12p83A, li_FeXX_12p85A, li_FeLyAlpha, li_FeHeTripR, li_FeHeTripI, li_FeHeTripF ]; ()=system ("rm lil_group.txt"); save_group(lil_group, "lil_group.txt"); list_group; %-------------------------------------------------------- %-------------------------------------------------------- % My useful additional routines % % region and bump structures, etc. ()=evalfile("rg_setup.i"); %-------------------------------------------------------- % Use XSPEC library... import("xspec"); %-------------------------------------------------------- % demo plot of the em model window(p1); xrange(0.0,26.0); ylog; yrange(0.01,10.0*max(mod_em/1.E42)); hplot(mod_binlo, mod_binhi, mod_em/1.E42, yellow); % Add labels to the plot ()=evalfile("plot_all_groups.i"); %-------------------------------------------------------- % That's it. %--------------------------------------------------------