XMM data reduction: part II SAS command-line analysis and scripting Andy Read.

Slides:



Advertisements
Similar presentations
JQuery MessageBoard. Lets use jQuery and AJAX in combination with a database to update and retrieve information without refreshing the page. Here we will.
Advertisements

XMM-Newton 1 Matthias Ehle - SCI-OAX EPIC BGWG Meeting#6 November 5 th, 2007 BGWG Report from the June XMM-Newton User Group Meeting Matthias Ehle.
Overview Review of the Goddard method Update on instrument/detector evolution (a purely phenomenological approach) Characterization of the soft proton.
XMM EPIC MOS Jenny Carter 4 th EPIC BG WG Meeting Mallorca, 25/10/06 BGWG blank sky data analysis Jenny Carter, University of Leicester.
XMM EPIC MOS Jenny Carter 5 th EPIC BG WG Meeting Palermo,11/04/07 BGWG blank sky updates and pn soft proton analysis Jenny Carter,
XMM EPIC Andy Read IACHEC 2013 Leicestershire, UK, 25-28/03/13 XMM-Newton EPIC Cross- Calibration Andy Read With contributions from Matteo.
MOS Pn cross calibration with a sample of Galaxy Clusters MOS Pn cross calibration with a sample of Galaxy Clusters Alberto Leccardi & Silvano Molendi.
XMM EPIC MOS Andy Read 2 nd EPIC BG WG Meeting MPE, Germany 24/11/05-25/11/05.
MOS 3x3 mode slow slew survey Richard Saxton October 2006.
Images script M. Ehle & Rosemary Willatt (ESAC) April 2007.
XMM EPIC MOS Andy Read for the BGWG CAL/OPS/BG Meeting Palermo, Sicily 11-13/04/07 EPIC Background Working Group Summary: Meeting.
Analysis of the soft response of pn and MOS with a sample of blazars Silvano Molendi (IASF-MI)
XMM-Newton 1 Michael Smith, ESAC PN Monitoring Mallorca, October 2006.
XMM EPIC MOS Andy Read EPIC CAL/OPS Meeting Mallorca, Spain 26-27/10/06 EPIC BGWG XMM-Newton EPIC BackGround Working Group founded.
XMM EPIC MOS Andy Read 6 th EPIC BG WG Meeting Mallorca, Spain 05/11/07 Agenda:
XMM data reduction with SAS Simon Vaughan (original notes by Tim Roberts)
Guide To UNIX Using Linux Third Edition
Introduction to Unix (CA263) Introduction to Shell Script Programming By Tariq Ibn Aziz.
XMM EPIC MOS Andy Read EPIC CAL/OPS Meeting MPE, Germany 04-05/05/06 EPIC BGWG XMM-Newton EPIC BackGround Working Group founded (~1.
Shell Programming 1. Understanding Unix shell programming language: A. It has features of high-level languages. B. Convenient to do the programming. C.
Shell Programming, or Scripting Shirley Moore CPS 5401 Fall August 29,
Line up By Melissa Dalis Professor Susan Rodger Duke University June 2011.
CLEO’s User Centric Data Access System Christopher D. Jones Cornell University.
Copyright 2007, Information Builders. Slide 1 Maintain & JavaScript: Two Great Tools that Work Great Together Mark Derwin and Mark Rawls Information Builders.
Introduction to Shell Script Programming
CPSC 171 Introduction to Computer Science 3 Levels of Understanding Algorithms More Algorithm Discovery and Design.
X-ray Astronomy School 2007 Databases, software, etc. for X-ray astronomy Keith Arnaud NASA Goddard University of Maryland.
1 Operating Systems Lecture 3 Shell Scripts. 2 Shell Programming 1.Shell scripts must be marked as executable: chmod a+x myScript 2. Use # to start a.
1 Operating Systems Lecture 3 Shell Scripts. 2 Brief review of unix1.txt n Glob Construct (metacharacters) and other special characters F ?, *, [] F Ex.
Review of 2XMMp data products Anja Schröder, Univ of Leicester, UK John Pye, Univ of Leicester, UK.
Computational Methods of Scientific Programming Lecturers Thomas A Herring, Room A, Chris Hill, Room ,
HIFI Tutorial 3: Getting some basic science out A.P.Marston ESAC 27 June 2013.
08/10/ Iteration Loops For … To … Next. 208/10/2015 Learning Objectives Define a program loop. State when a loop will end. State when the For.
Galaxy for Bioinformatics Analysis An Introduction TCD Bioinformatics Support Team Fiona Roche, PhD Date: 31/08/15.
File I/O 11_file_processing.ppt
Exploring an Open Source Automation Framework Implementation.
Copyright © The McGraw-Hill Companies, Inc. Introduction to MATLAB for Engineers, Third Edition William J. Palm III Chapter 1 An Overview of MATLAB.
Shell Script Programming. 2 Using UNIX Shell Scripts Unlike high-level language programs, shell scripts do not have to be converted into machine language.
XMM EPIC MOS Andy Read 3 rd EPIC BG WG Meeting MPE, Germany 02/05/06.
A multi-colour survey of NGC253 with XMM-Newton Robin Barnard, Lindsey Shaw Greening & Ulrich Kolb The Open University.
SAG+SASWG Meeting Potsdam /15 PN Tasks – Status Report (update since Leicester) Hermann Brunner - MPE  epframes:  The dark quadrant problem.
Indexed and Relative File Processing
File Input and Output in C++. Keyboard and Screen I/O #include cin (of type istream) cout (of type ostream) Keyboard Screen executing program input data.
Introduction to RHESSI Data Analysis Documentation Data Products Access to Data SSW Analysis Modes RHESSI GUI Combining GUI and Command Line RHESSI Objects.
BMTRY 789 Lecture 11: Debugging Readings – Chapter 10 (3 rd Ed) from “The Little SAS Book” Lab Problems – None Homework Due – None Final Project Presentations.
PACS NHSC Data Processing Workshop – Pasadena 10 th - 14 th Sep 2012 The SPIRE Destriper Bernhard Schulz NHSC/IPAC on behalf of the SPIRE ICC 1.
LIN Unix Lecture 5 Unix Shell Scripts. LIN Command Coordination ; && || command1 ; command2 Interpretation: Do command 1. Then do command.
Pipeline Basics Jared Crossley NRAO NRAO. What is a data pipeline?  One or more programs that perform a task with reduced user interaction.  May be.
Chapter 11Java: an Introduction to Computer Science & Programming - Walter Savitch 1 Chapter 11 l Basics of Recursion l Programming with Recursion Recursion.
Agenda Positional Parameters / Continued... Command Substitution Bourne Shell / Bash Shell / Korn Shell Mathematical Expressions Bourne Shell / Bash Shell.
1 Project designed and created by M. Shajith Kumar.
EOVSA Pipeline Processing System J. McTiernan EOVSA Prototype Review 24-Sep-2012.
Page 1 NHSC PACS Web Tutorial PACS 301 nhsc.ipac.caltech.edu/helpdesk NHSC/PACS Web Tutorials Running the PACS Spectrometer pipeline for CHOP/NOD Mode.
HIFI Tutorial 1: Running the HIFI Pipelines and Adaptations A.P.Marston ESAC 27 June 2013.
NMD202 Web Scripting Week2. Web site
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. A Concise Introduction to MATLAB ® William J. Palm III.
X-ray Astronomy School 2005 Databases, software, etc. for X-ray astronomy Keith Arnaud NASA Goddard University of Maryland.
CSC 4630 Meeting 17 March 21, Exam/Quiz Schedule Due to ice, travel, research and other commitments that we all have: –Quiz 2, scheduled for Monday.
EOVSA Data and Database System J. McTiernan EOVSA Technical DesignMeeting 7-Nov-2011.
June 27-29, DC2 Software Workshop - 1 Tom Stephens GSSC Database Programmer GSSC Data Servers for DC2.
CSC 4630 Perl 3 adapted from R. E. Beck. Problem But we worked on it first: Input: Read from a text file named in a command line argument Output: List.
CS 403: Programming Languages Lecture 20 Fall 2003 Department of Computer Science University of Alabama Joel Jones.
Structured Computer Programming EE 201 Introduction to MATLAB 7 for Engineers بسم الله الرحمن الرحيم King Abdulaziz University College of Engineering Dept.
Functional Processing of Collections (Advanced) 6.0.
Gerard Fitzpatrick Tutor: Andy Pollock Trainee Project 2009
Introduction to MATLAB for Engineers, Third Edition
T. Jumana Abu Shmais – AOU - Riyadh
Fundamentals of Python: First Programs
CST8177 Scripting 2: What?.
More Loops Topics Relational Operators Logical Operators for Loops.
Presentation transcript:

XMM data reduction: part II SAS command-line analysis and scripting Andy Read

Weds 14th Dec 2005 XMM data reduction: part II 2 Overview Command-line examples/help Why use command-line and scripts? Example scripts : SASmakecalev & SASprepareXMM Imaging scripts & spectral scripts Scripts within scripts Final remarks

Weds 14th Dec 2005 XMM data reduction: part II 3 Setting up the user environment To run on XROA system: > sas-setup initialises software > setenv SAS_ODF (path_to_ODF_directory) e.g. /data/71/tro/xmm_data/ /odf/ > setenv SAS_CCFPATH /data/rb2/sas_ccf > cifbuild fullpath=yes >& cifbuild.log builds ccf.cif – calibration index file > setenv SAS_CCF (path_to_ccf.cif_file) > odfingest odfdir=$SAS_ODF outdir=$SAS_ODF >& odfingest.log builds ***SUM.SAS file in ODF directory – ODF summary file necessary for reprocessing (from Tim’s talk) Command line examples

Weds 14th Dec 2005 XMM data reduction: part II 4 Command line help - Simple help – parameters and default values

Weds 14th Dec 2005 XMM data reduction: part II 5 - More - Parameters, parameter types, default values and ‘one-line’ help

Weds 14th Dec 2005 XMM data reduction: part II 6 - Full help – Links to SAS web pages - Cut and paste link into browser

Weds 14th Dec 2005 XMM data reduction: part II 7 Why use scripts? Useful scripting cookbook at Scripts are just a list of command-line calls/commands run sequentially - There are many powerful command line calls - Can run intensive analysis on many datasets, sources etc. - Can be sure of doing exactly the same thing every time, e.g. running exactly the same procedures on many sources/datasets - No need for interactive use - can run overnight (no need to be there) - can run as cron jobs (no need to be even logged in) - Often need to redo entire analysis, e.g. - New calibration files - New ODF files - Mistake, change in e.g. source positions, detection threshold etc.

Weds 14th Dec 2005 XMM data reduction: part II 8 Example script : SASmakecalev

Weds 14th Dec 2005 XMM data reduction: part II 9 Executable t-shell script Comment lines Runs at low priority On-screen help – appears whenever incorrect number of arguments is given (e.g. zero) Number of arguments If correct number of arguments is given (7) then input arguments (1-7) converted to parameters used in script, and we move into the main body of the script

Weds 14th Dec 2005 XMM data reduction: part II 10 Check that ODF exists (otherwise exit) Get SAS version (for directory naming) Create (if necessary) output directory, and (if allowed) enter

Weds 14th Dec 2005 XMM data reduction: part II 11 Check ODF Set SAS_ODF environment variable Check for ***SUM.SAS file (Check for ***SUM.ASC file) Create ccf.cif – calibration index file Set SAS_CCF environment variable Create ***SUM.SAS file in ODF directory – ODF summary file necessary for reprocessing Output all SAS environment variables to screen – useful check

Weds 14th Dec 2005 XMM data reduction: part II 12 Run emproc (if required) Run emchain (if required) Run epproc (if required) Run epchain (if required) List created final calibrated event lists and exit

Weds 14th Dec 2005 XMM data reduction: part II 13 Run script

Weds 14th Dec 2005 XMM data reduction: part II 14 Example script : SASprepareXMM

Weds 14th Dec 2005 XMM data reduction: part II 15 Soft Proton flaring in an observation of a Galaxy Group

Weds 14th Dec 2005 XMM data reduction: part II 16 Executable t-shell script Comment lines Runs at low priority On-screen help – appears whenever incorrect number of arguments is given (e.g. none) Number of arguments

Weds 14th Dec 2005 XMM data reduction: part II 17 If correct number of arguments is given (9) then input arguments (1-9) converted to parameters used in script If requested : Check ODF Check for ***SUM.SAS file Create ***SUM.SAS file in ODF Set SAS_ODF environment variable

Weds 14th Dec 2005 XMM data reduction: part II 18 If requested : Create ccf.cif – calibration index file Set SAS_CCF environment variable Output all SAS environment variables to screen – useful check

Weds 14th Dec 2005 XMM data reduction: part II 19 Convert patcode parameter into an expression for evselect

Weds 14th Dec 2005 XMM data reduction: part II 20 MOS1 example (comment)

Weds 14th Dec 2005 XMM data reduction: part II 21 If $m1 does not equal 0, OK – continue to next line If $m1 equals 0, ignore this whole section

Weds 14th Dec 2005 XMM data reduction: part II 22 If $m1 equals F, then we attempt to find the file Else, the file name is given by the parameters

Weds 14th Dec 2005 XMM data reduction: part II 23 Remove a temporary file if it already exists

Weds 14th Dec 2005 XMM data reduction: part II 24 Long list all the MOS1 event files in the directory to temporary file

Weds 14th Dec 2005 XMM data reduction: part II 25 Count the number of entries (MOS1 event files) in the temporary file

Weds 14th Dec 2005 XMM data reduction: part II 26 If only one MOS1 event file, use this

Weds 14th Dec 2005 XMM data reduction: part II 27 If more than one MOS1 event file, try to find the largest

Weds 14th Dec 2005 XMM data reduction: part II 28 Initiate loop through ‘i’ (i=0)

Weds 14th Dec 2005 XMM data reduction: part II 29 loop through ‘i’ until ‘i’ equals number of event files, then end

Weds 14th Dec 2005 XMM data reduction: part II 30 Increment ‘i’ by +1 (i=1)

Weds 14th Dec 2005 XMM data reduction: part II 31 Get size of ‘i’th file : Type the file, extract the top (head) ‘i’ lines, then extract the bottom (tail) line – file size is the 5 th string in long listing

Weds 14th Dec 2005 XMM data reduction: part II 32 If size of ‘i’th file is larger than largest recorded, note ‘i’ (‘ibig’) and size as largest recorded

Weds 14th Dec 2005 XMM data reduction: part II 33 Loop round to next ‘i’

Weds 14th Dec 2005 XMM data reduction: part II 34 Get name of largest file (i.e. file corresponding to ‘ibig’) : Type the file, extract the top (head) ‘ibig’ lines, then extract the bottom (tail) line – file name is the 9 th string in long listing Set $m1 to this filename

Weds 14th Dec 2005 XMM data reduction: part II 35 Create (evselect) lightcurve : High-energy, single events, ‘good’ flags, 100s bins

Weds 14th Dec 2005 XMM data reduction: part II 36 Output help to screen: What is being done, what the user should do

Weds 14th Dec 2005 XMM data reduction: part II 37 Plot (dsplot) the light curve to the screen for user to examine

Weds 14th Dec 2005 XMM data reduction: part II 38 Request upper and lower threshold values from user

Weds 14th Dec 2005 XMM data reduction: part II 39 Use threshold values to create (tabgtigen) good times GTI file

Weds 14th Dec 2005 XMM data reduction: part II 40 Create (evselect) intermediate event file : filter on low-E threshold, pattern, flags, etc.

Weds 14th Dec 2005 XMM data reduction: part II 41 Create (evselect) final event file : filter intermediate file for good times using GTI file

Weds 14th Dec 2005 XMM data reduction: part II 42 Same for MOS2

Weds 14th Dec 2005 XMM data reduction: part II 43 Same for pn

Weds 14th Dec 2005 XMM data reduction: part II 44

Weds 14th Dec 2005 XMM data reduction: part II 45 Enter MOS1 thresholds Same for MOS2 Same for pn New filtered event files (r1***EV***) smaller than originals

Weds 14th Dec 2005 XMM data reduction: part II 46 Already seen xmmselect GUI - clean data, and produce science products Only handles one dataset at a time Essentially a handy GUI ‘wrapper’ to the SAS-task ‘evselect’ evselect is the command-line workhorse of SAS analysis tasks Many scripts are command-line ‘wrappers’ of evselect and other SAS-tasks

Weds 14th Dec 2005 XMM data reduction: part II 47 Script to create images - Essentially an evselect wrapper, plus other tasks (e.g. asmooth)

Weds 14th Dec 2005 XMM data reduction: part II 48 MOS1 MOS1 smoothed MOS2 MOS2 smoothed pn pn smoothed e.g eV sky (X/Y) 2′′ images (raw and smoothed) [MOS-sdtq, pn-sd]

Weds 14th Dec 2005 XMM data reduction: part II 49 Script to create spectra + ARF, RMF and do grouping etc. Again, evselect wrapper, plus arfgen, rmfgen, grppha etc… SAS-task equivalent especget now much improved

Weds 14th Dec 2005 XMM data reduction: part II 50 createspectrum to create BG spectrum Note: can set parameters (here, co-ordinates from Tim’s region files) on the command line Run script (using parameters)

Weds 14th Dec 2005 XMM data reduction: part II 51 createspectrum to create source spectrum, ARF, RMF and group final spectrum

Weds 14th Dec 2005 XMM data reduction: part II 52

Weds 14th Dec 2005 XMM data reduction: part II 53 Can put each step/script into a file (e.g. analysis) – A script to call other scripts Can then run whole ‘analysis’: > source analysis

Weds 14th Dec 2005 XMM data reduction: part II 54 Homework (2005) Extract NGC 1313 data (Oct 2000) from XSA Set up analysis environment Filter data for background flares Extract 0.3 – 10 keV images for all three detectors Extract spectra of NGC 1313 X-1 Compare your results to  /data/71/tro/xmm_data/ /work/ Homework (2006) – use scripts (and write a script of your scripts) to do all the analysis

Weds 14th Dec 2005 XMM data reduction: part II 55 Resources This talk (and others):  The scripts (and others):  XMM-Newton SAS web pages  Via  Particularly useful documentation: HEASARC ABC guide SAS user’s guide Experienced users!