dlXRTΒΆ
dlXRT is used for download necessary files for Swift-XRT and Swift-BAT data analysis.
Input: observation ID and instrument name
Output: event file, housekeeping file and attitude file
Example:
./dlxrt
Please input the observation ID (eg.00554620000):
00554620000
Please input instrument xrt/bat (eg. xrt):
xrt
......
......
Download finished.
Source code:
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 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 | #!/usr/bin/perl
require "./libswxrt.pl";
# This script is for downloading data from Swift website
our %Task = (
name => 'dlxrt',
version => '0.6',
releasedate => "2013-10-6",
chatter => 2,
status => 0,
errmess => '',
stem => '',
author => 'Y.Wang',
);
## Enter observational ID and Instrument
my $obsID = $ARGV[0] if ($ARGV[0]);
my $inst = $ARGV[1] if ($ARGV[1]);
my $doXrt = "no"; #if download XRT data
my $doBat = "no"; #if download Bat data
#my $doUvot = "yes"; # if download UVOT data
unless(defined $obsID){
print "Please input the observation ID (eg.00554620000):\n";
chomp($obsID = <STDIN>);
}
unless(defined $inst){
print "Please input instrument xrt/bat (eg. xrt):\n";
chomp($inst = <STDIN>);
}
$doXrt = "yes" if $inst eq "xrt" or $inst eq "XRT";
$doBat = "yes" if $inst eq "bat" or $inst eq "BAT";
my $trigger = substr($obsID,2,6);
my $grbName;
### Download List
#### XRT file list
#my $sat_fits = "http://www.swift.ac.uk/archive/reproc/"."$obsID"."/auxil/sw"."$obsID"."sat.fits.gz";
#my $sat_fits_pat = "http://www.swift.ac.uk/archive/reproc/"."$obsID"."/auxil/sw"."$obsID"."pat.fits.gz";
#my $sat_fits_uat = "http://www.swift.ac.uk/archive/reproc/"."$obsID"."/auxil/sw"."$obsID"."uat.fits.gz";
my $xhd_hk = "http://www.swift.ac.uk/archive/reproc/"."$obsID"."/xrt/hk/sw"."$obsID"."xhd.hk.gz";
my $pcw3_cl_evt = "http://www.swift.ac.uk/archive/reproc/"."$obsID"."/xrt/event/sw"."$obsID"."xpcw3po_cl.evt.gz";
my $wtw2_cl_evt = "http://www.swift.ac.uk/archive/reproc/"."$obsID"."/xrt/event/sw"."$obsID"."xwtw2po_cl.evt.gz";
#my @downloadListXrt = ($sat_fits, $sat_fits_pat, $sat_fits_uat, $xhd_hk, $pcw3_cl_evt, $wtw2_cl_evt);
my @downloadListXrt = ($xhd_hk, $pcw3_cl_evt, $wtw2_cl_evt);
#### BAT file list
my $bat_uf_evt = "http://www.swift.ac.uk/archive/reproc/"."$obsID"."/bat/event/sw"."$obsID"."bevshsp_uf.evt.gz";
my $bdecb_hk = "http://www.swift.ac.uk/archive/reproc/"."$obsID"."/bat/hk/sw"."$obsID"."bdecb.hk.gz";
my $bdqcb_hk = "http://www.swift.ac.uk/archive/reproc/"."$obsID"."/bat/hk/sw"."$obsID"."bdqcb.hk.gz";
my $fits_bevtr = "http://www.swift.ac.uk/archive/reproc/"."$obsID"."/bat/event/sw"."$obsID"."bevtr.fits.gz";
#my @downloadListBat = ($sat_fits, $sat_fits_pat, $sat_fits_uat, $bat_uf_evt, $bdecb_hk, $bdqcb_hk, $fits_bevtr);
my @downloadListBat = ($bat_uf_evt, $bdecb_hk, $bdqcb_hk, $fits_bevtr);
### Find Name and Make folder
my $nameListWeb = "http://www.swift.ac.uk/grb_region/";
my $grbName = $trigger;
system 'curl',"$nameListWeb","-o","name.list";
open my $nameList, '<', "name.list";
while (<$nameList>) {
if(/.*$trigger.*GRB\s(\w+)</){
$grbName = $1 ;
}
}
close $nameList;
system 'rm -f name.list';
print "Data are stored in the forder $grbName.\n";
mkdir "$grbName" unless (-e "$grbName");
chdir("$grbName");
mkdir "$obsID" unless (-e "$obsID");
chdir("$obsID");
### download XRT data
if ($doXrt eq "yes"){
mkdir "xrt" unless (-e "xrt");
chdir("xrt");
foreach $file (@downloadListXrt){
system 'wget','--no-check-certificate','--no-clobber',"$file";
}
#system 'gzip --decompress --force --keep *.evt.gz';
#system 'rm -r *.evt.gz';
## download attitude file
my $attFlag, $attflagPC, $attflagWT, $attFile, $att_fits;
my $pcEvent = "sw"."$obsID"."xpcw3po_cl.evt.gz";
my $wtEvent = "sw"."$obsID"."xwtw2po_cl.evt.gz";
&GetKeyword($pcEvent, 'EVENTS', undef, 'ATTFLAG', \$attflagPC, undef);
$Task{status} = 0;
&GetKeyword($wtEvent, 'EVENTS', undef, 'ATTFLAG', \$attflagWT, undef);
$attFlag = $attflagPC if $attflagPC;
$attFlag = $attflagWT if $attflagWT;
&PrntChty(2, "ATTFLAG is $attFlag \n");
#my $evtFilenameEvents="$evtFilename"."[Events]";
#my $att = `ftlist $evtFilenameEvents k include=HISTORY`;
$attFile="sw"."$obsID"."pat.fits.gz" if $attFlag eq "110";
$attFile="sw"."$obsID"."sat.fits.gz" if $attFlag eq "100";
$attFile="sw"."$obsID"."uat.fits.gz" if ($attFlag eq "111" or $attFlag eq "101");
$att_fits = "http://www.swift.ac.uk/archive/reproc/"."$obsID"."/auxil/"."$attFile";
&PrntChty(2, "Attitude file is $att_fits \n");
system 'wget','--no-check-certificate','--no-clobber',"$att_fits";
chdir("..");
}
### download bat data
if ($doBat eq "yes"){
mkdir "bat" unless (-e "bat");
chdir("bat");
foreach $file (@downloadListBat){
system 'wget','--no-check-certificate','--no-clobber',"$file";
}
#system 'gzip --decompress --force --keep *.evt.gz';
#system 'rm -r *.evt.gz';
my $attFlag, $attflagPC, $attflagWT, $attFile, $att_fits;
my $batEvent = "sw"."$obsID"."bevshsp_uf.evt.gz";
&GetKeyword($batEvent, 'EVENTS', undef, 'ATTFLAG', \$attFlag, undef);
&PrntChty(2, "ATTFLAG is $attFlag \n");
#my $evtFilenameEvents="$evtFilename"."[Events]";
#my $att = `ftlist $evtFilenameEvents k include=HISTORY`;
$attFile="sw"."$obsID"."pat.fits.gz" if $attFlag eq "110";
$attFile="sw"."$obsID"."sat.fits.gz" if $attFlag eq "100";
$attFile="sw"."$obsID"."uat.fits.gz" if ($attFlag eq "111" or $attFlag eq "101");
$att_fits = "http://www.swift.ac.uk/archive/reproc/"."$obsID"."/auxil/"."$attFile";
&PrntChty(2, "Attitude file is $att_fits \n");
system 'wget','--no-check-certificate','--no-clobber',"$att_fits";
chdir("..");
}
&PrntChty(2, "Download finished. \n");
|