#!/bin/csh -f # # "do-jemx-science-analysis" # # This script works for JEMX ISSW running on rev_2 data such as those # downloaded from Stockholm. # # Version 2.0 2005-09-13/NJW Include possibility of revised data (rev.002) # in archive in /lin6/data/arc/rev_2 # Version 2.1 2007-01-18/NJW Using OSA6.0 # Version 2.2 2007-01-29/NJW Copying .par files to local dir # Version 2.3 2007-11-27/NL Using OSA7.0 # Version 3.0 2009-01-09/NJW No longer tied to ../analysis7 # Version 8.5 2016-02-25/NJW Using OSA10.3 (OSA10.2 with new j_ima_iros) # Version 8.6 2016-02-26/NL Modified for NL environment # # Syntax: dojsa_nl # # This version takes parameters either from the command line or from "dojsa_nl.par" # in the IRAF and DAL fashion: dojsa_nl obsDir=work jemxNum=2 # _but_ use the +exten convention in stead of the [exten] convention # # Environment variables: JARCHIVE can be: NRTDATA # # Required input: # 1) The file 'swid.list' with a table of the 12 digit SWIDs to analyze # 2) The file 'ebin.list' with energy limits given in keV # Three lines e.g. identifier e.g. a2 # Number_of_energy_bins e.g. 2 # 4.0 6.0 10.0 14.5 # These energies are interpreted by 'kev2pi -dn ...' # # Files produced: jemx.lst for og_create is copied to ../analysis # rev.list contains the 4 digit revolution numbers # tmp is a temporary file used # The result is stored under ../analysis/obs/$OBSDIR # # Required executables: str_wrap # falign # mstrstr # get_insta_swijd # if ( ! -e swid.list ) then echo No file: swid.list exists - terminate exit 0 endif if ( ! -e ebin.list ) then echo No file: ebin.list exists - terminate exit 0 endif if ( ! -e setup_env ) then echo No file: setup_env exists - terminate exit 0 endif # echo zzzz echo This is dojsa_qqq_104 echo and JARCHIVE is $JARCHIVE echo zzzz # # Set flag for saving resulting files # set FLAG = 0 #set RESULTPATH = /nfs/jemx/nl_mosa # # Set the call parameters # set ALLPARAMS = "$argv[*]" set OBSDIR = `script_get_par dojsa_nl obsDir $ALLPARAMS` set JEMXNUM = `script_get_par dojsa_nl jemxNum $ALLPARAMS` set ENDLEVEL = `script_get_par dojsa_nl endLevel $ALLPARAMS` set SKIPLEVELS = `script_get_par dojsa_nl skipLevels $ALLPARAMS` set STARTLEVEL = `script_get_par dojsa_nl startLevel $ALLPARAMS` set INSTMOD = `script_get_par dojsa_nl instMod $ALLPARAMS` if ( $INSTMOD != "" ) set INSTMOD = `plus2brack $INSTMOD` set RESPONSE = `script_get_par dojsa_nl response $ALLPARAMS` if ( $RESPONSE != "" ) set RESPONSE = `plus2brack $RESPONSE` set DOLBPL = `script_get_par dojsa_nl dolBPL $ALLPARAMS` if ( $DOLBPL != "" ) set DOLBPL = `plus2brack $DOLBPL` set USRCAT = `script_get_par dojsa_nl usrCat $ALLPARAMS` if ( $USRCAT != "" ) set USRCAT = `plus2brack $USRCAT` set GAINHIST = `script_get_par dojsa_nl gainHist $ALLPARAMS` if ( $GAINHIST != "" ) set GAINHIST = `plus2brack $GAINHIST` set GAINMODEL = `script_get_par dojsa_nl gainModel $ALLPARAMS` set SKYIMAGESOUT = `script_get_par dojsa_nl skyImagesOut $ALLPARAMS` set USEIROS = `script_get_par dojsa useIROS $ALLPARAMS` set TIMESTEP = `script_get_par dojsa timeStep $ALLPARAMS` # # Set the local path to templates # set LOCALTEMPLATES = /home/njw/jemx/issw/templates_osa103 # # Make *.par files for this particular run # and set PFILES accordingly # setenv STARTDIR $PWD mkdir pfiles cd pfiles cp /home/njw/pfiles_osa104/j_export_par_osa104.tar . tar xf j_export_par_osa104.tar cd .. set LOCALPFILES = "$STARTDIR/pfiles;" set GNRLREFRCATPATH = /r6/jemx/catalogs # # Display parameters # echo obsDir: $OBSDIR echo jemxNum: $JEMXNUM echo startLevel: $STARTLEVEL echo endLevel: $ENDLEVEL echo instMod: "$INSTMOD" echo response: "$RESPONSE" echo dolBPL: "$DOLBPL" echo usrCat: "$USRCAT" echo gainHist: "$GAINHIST" echo gainModel: $GAINMODEL echo skyImagesOut: $SKYIMAGESOUT # # Log parameters in dojsa_nl.log # echo ------- `date` -------- >> dojsa_nl.log echo obsDir: $OBSDIR >> dojsa_nl.log echo jemxNum: $JEMXNUM >> dojsa_nl.log echo startLevel: $STARTLEVEL >> dojsa_nl.log echo endLevel: $ENDLEVEL >> dojsa_nl.log echo instMod: "$INSTMOD" >> dojsa_nl.log echo response: "$RESPONSE" >> dojsa_nl.log echo dolBPL: "$DOLBPL" >> dojsa_nl.log echo usrCat: "$USRCAT" >> dojsa_nl.log echo gainHist: "$GAINHIST" >> dojsa_nl.log echo gainModel: $GAINMODEL >> dojsa_nl.log echo skyImagesOut: $SKYIMAGESOUT >> dojsa_nl.log echo localpfiles: $LOCALPFILES >> dojsa_nl.log echo swid.list first line: `head -1 swid.list` >> dojsa_nl.log echo ebin.list first line: `head -1 ebin.list` >> dojsa_nl.log # if ( $JEMXNUM != 1 && $JEMXNUM != 2 ) then echo Illegal JEMX number - terminate exit 0 endif ##if ( $JEMXNUM == 1 ) set INSTRU = 4 ##if ( $JEMXNUM == 2 ) set INSTRU = 5 # # # Identify number of energy bins # set BINID = `head -1 ebin.list` set NEBINS = `head -2 ebin.list | tail -1` kev2pi `tail -1 ebin.list` > tmp_kev2pi set CHANLOW = `head -1 tmp_kev2pi` set CHANHIGH = `tail -1 tmp_kev2pi` # # Produce the revolution list # cut -c 1-4 swid.list > rev.list echo the file rev.list has been produced set REVOL = `head -1 rev.list` set SWID = `head -1 swid.list` set RMFINSTANCE = `get_insta_swijd -swid $SWID $JEMXNUM rmf 15` if ( "$RESPONSE" == "" ) then set RESPONSE = "/r6/jemx/ic/rmf_grp/jmx${JEMXNUM}_rmf_grp_$RMFINSTANCE.fits[1]" echo "response set to default: $RESPONSE" >> dojsa_nl.log endif # # If there are several revolutions involved then # issue a warning if level SPE is requested # if ( $ENDLEVEL == "SPE" ) then sort -u rev.list > rev.ulist set NUMDIFFREV = `wclines rev.ulist` echo $NUMDIFFREV different revolutions are requested if ( $NUMDIFFREV > 1 ) then echo "*********************************************" echo "*" echo "* NB - level SPE is requested and there are $NUMDIFFREV different revolutions" echo "*" echo "*********************************************" endif endif # falign rev.list swid.list / > tmp # source setup_env echo $PATH > current_path.txt # # Analyze environment variable JARCHIVE # if ( $JARCHIVE == "NRTDATA" ) then str_wrap 00 "./scw/" ".000/swg.fits[1]" < tmp > jemx.lst source setup_links_nrt else source setup_links_jarc # find out if rev.002 exists for each SWID if ( -e tmpq ) /bin/rm tmpq foreach qqq ( `cat tmp` ) if ( -e ./scw/${qqq}.002/swg.fits ) then echo .002 >> tmpq else if ( -e ./scw/${qqq}.001/swg.fits ) then echo .001 >> tmpq else echo .000 >> tmpq endif endif end falign tmp tmpq "" > tmpr str_wrap 00 "./scw/" "/swg.fits[1]" < tmpr > jemx.lst #source setup_links_arc_lin6 endif # # Remove old directory if it exists # if ( -d obs/$OBSDIR ) rm -r obs/$OBSDIR # # Create the observation group # setenv PFILES "${LOCALPFILES}" og_create idxSwg=jemx.lst ogid=$OBSDIR baseDir="./" instrument=JEMX$JEMXNUM # # --- get rid of the SCP. (e-mail from Stephane Paltani 2009-11-27) # cd obs/$OBSDIR dal_detach og_jmx${JEMXNUM}.fits pattern="JMX${JEMXNUM}-GAIN-SCP" # # running jemx_science_analysis # setenv PFILES "${LOCALPFILES}" # # jemx_science_analysis ogDOL="og_jmx$JEMXNUM.fits[1]" \ jemxNum="$JEMXNUM" \ startLevel="$STARTLEVEL" \ endLevel="$ENDLEVEL" \ skipLevels="" \ COR_gainHist="$GAINHIST" \ COR_gainModel="$GAINMODEL" \ CAT_I_refCat="$GNRLREFRCATPATH/gnrl_refr_cat_0027.fits[1]" \ CAT_I_usrCat="$USRCAT" \ GTI_gtiJemxNames="" \ skipLevels="BKG" \ instMod="$INSTMOD" \ nChanBins="$NEBINS" \ chanLow="$CHANLOW" \ chanHigh="$CHANHIGH" \ radiusLimit=125. \ timeStart=-1.0 \ timeStop=-1.0 \ BIN_I_shdType=2 \ IMA_detAccLimit=65535 \ IMA_detSigSingle=20.0 \ IMA_makeNewBPL=no \ IMA_newBackProjFile="" \ IMA_loopLimitPeak=0.025 \ IMA_skyImageDim=2 \ IMA_bkgShdDOL="empty" \ # IMA_bkgShdDOL="jmx2_src_lc.fits(JMX2-SRC.-LCR-IDX.tpl)" \ IMA_dolBPL="$DOLBPL" \ IMA_pixelFold=1 \ IMA_skyImagesOut="$SKYIMAGESOUT" \ IMA_useTrace=n \ IMA_tracestring="FFFFFFFFFFFFFFFF" \ IMA_detImagesOut=n \ IMA_userImagesOut=n \ response="$RESPONSE" \ LCR_useIROS="$USEIROS" \ LCR_doBurstSearch=y \ LCR_burstThreshSrc=7. \ LCR_burstThreshDet=6. \ LCR_vignCorr="y" \ LCR_timeStep="$TIMESTEP" \ LCR_referenceTime=0. \ LCR_vignCorr="y" \ LCR_timeStep=4.0 \ LCR_evtType=0 \ LCR_useRaDec=y # ebm_set_par ${STARTDIR}/pfiles/j_ima_iros.par userImagesOut=1 \ # # Stop here if FLAG has not been set to 1 # if( $FLAG != 1 ) exit # # Make copies of the crucial files # #find scw -name jmx${JEMXNUM}_evts_shd.fits -print > tmpa #if ( 0 != `wcchar tmpa` ) then # extr_swids < tmpa | str_wrap 00 "" .fits > tmpb # str_wrap mv "$RESULTPATH/evts_shd/jmx${JEMXNUM}_evts_shd${BINID}_" < tmpa > tmpc # falign tmpc tmpb "" > tmpa # source tmpa #endif # find scw -name jmx${JEMXNUM}_sky_ima.fits -print > tmpa if ( 0 != `wcchar tmpa` ) then extr_swids < tmpa | str_wrap 00 "" .fits > tmpb str_wrap cp "$RESULTPATH/sky_ima/jmx${JEMXNUM}_sky_ima${BINID}_" < tmpa > tmpc falign tmpc tmpb "" > tmpa source tmpa endif # find scw -name jmx${JEMXNUM}_srcl_res.fits -print > tmpa if ( 0 != `wcchar tmpa` ) then extr_swids < tmpa | str_wrap 00 "" .fits > tmpb str_wrap cp "$RESULTPATH/srcl_res/jmx${JEMXNUM}_srcl_res${BINID}_" < tmpa > tmpc falign tmpc tmpb "" > tmpa source tmpa endif # find scw -name jmx${JEMXNUM}_srcl_spe.fits -print > tmpa if ( 0 != `wcchar tmpa` ) then extr_swids < tmpa | str_wrap 00 "" .fits > tmpb str_wrap cp "$RESULTPATH/srcl_res/jmx${JEMXNUM}_srcl_spe${BINID}_" < tmpa > tmpc falign tmpc tmpb "" > tmpa source tmpa endif # find scw -name jmx${JEMXNUM}_srcl_arf.fits -print > tmpa if ( 0 != `wcchar tmpa` ) then extr_swids < tmpa | str_wrap 00 "" .fits > tmpb str_wrap cp "$RESULTPATH/srcl_res/jmx${JEMXNUM}_srcl_arf${BINID}_" < tmpa > tmpc falign tmpc tmpb "" > tmpa source tmpa endif find scw -name jmx${JEMXNUM}_full_dsp.fits -print > tmpa if ( 0 != `wcchar tmpa` ) then extr_swids < tmpa | str_wrap 00 "" .fits > tmpb str_wrap cp "$RESULTPATH/srcl_res/jmx${JEMXNUM}_full_dsp${BINID}_" < tmpa > tmpc falign tmpc tmpb "" > tmpa source tmpa endif find scw -name jmx${JEMXNUM}_dete_lcr.fits -print > tmpa if ( 0 != `wcchar tmpa` ) then extr_swids < tmpa | str_wrap 00 "" .fits > tmpb str_wrap cp "$RESULTPATH/srcl_res/jmx${JEMXNUM}_dete_lcr${BINID}_" < tmpa > tmpc falign tmpc tmpb "" > tmpa source tmpa endif find scw -name jmx${JEMXNUM}_src_iros_lc.fits -print > tmpa if ( 0 != `wcchar tmpa` ) then extr_swids < tmpa | str_wrap 00 "" .fits > tmpb str_wrap cp "$RESULTPATH/srcl_res/jmx${JEMXNUM}_src_iros_lc${BINID}_" < tmpa > tmpc falign tmpc tmpb "" > tmpa source tmpa endif ##chmod a-w $RESULTPATH/sky_ima/jmx${JEMXNUM}*.fits