Saturday, August 25, 2012

Plot 3D in IDL

http://www.idlcoyote.com/tip_examples/plots3d.pro

http://idlastro.gsfc.nasa.gov/idl_html_help/PLOTS.html

Wednesday, July 4, 2012

ps2pdf with bounding box

To convert ps file to pdf using non-standard file size (default is A4) first read off the bounding box from the ps file :
%%BoundingBox: 0 0 1275 236

Then :
ps2pdf -dDEVICEWIDTHPOINTS=1275 -dDEVICEHEIGHTPOINTS=236 file.ps file.pdf


For ps files with offset or in general easier method:

ps2pdf file1.ps file2.pdf (give device width and height with added space if needed)
pdfcrop file2.pdf file3.pdf


For color images, default setting is to resort to lossy JPEG compression. To set to lossless compression for better images set options:
 -dAutoFilterColorImages=false  -dColorImageFilter=/FlateEncode

Expanded options list:
ps2pdf -sPAPERSIZE=a4  -dCompatibilityLevel=1.3  \
 -dEmbedAllFonts=true  -dSubsetFonts=true  -dMaxSubsetPct=100  \
 -dAutoFilterColorImages=false  -dColorImageFilter=/FlateEncode  \
 -dAutoFilterGrayImages=false  -dGrayImageFilter=/FlateEncode  \
 -dAutoFilterMonoImages=false  -dMonoImageFilter=/CCITTFaxEncode  \
 document.ps  document.pdf

The important thing for the image quality is AutoFilter...Images=false and ...ImageFilter=/FlateEncode. The first disables the automatic determination by Ghostscript of the "best" compression format, which tends to favour /DCTEncode, lossy JPEG encoding. The second set of options manually set the compression method to the lossless (de)flate encoding for colour and greyscale images and to CCITT encoding for monochrome images.



Tuesday, May 22, 2012

FFT

FFT in IDL vs Fortran

http://www.ssec.wisc.edu/~paulv/fft/fft_comparison.html

Sunday, May 13, 2012

Tuesday, May 1, 2012

Visit

Volume rendering :

Steps :

1. Open - > load variable
2. Add volume -> rho
3.  plotatts - > volume -> splatting
4. set Tranparency : plotatts -> 1D transfer function
The grey bar denotes colors that are plotted. Removing grey area means those colors WILL NOT be shown in the 3-d rendering
5. choose color scale. hot desaturated is good.
6. Raycasting (composting) 600 points look ok


Make 3D vector field stream lines:

First create a vector vtk file with 3 components. Use Write_vtk,qx,qy,qz IDl routine

> Load vecfield

> Pseudocolor-->operators-->IntegralCurve-->vecfield

Click on Integral Curve to open operator attributes. Adjust as per choice.
Common adjusts:
1. source type: circle
2. Choose circle radius etc
3. Integration direction: Both for up and downsteam both.
4. Tab: Appearance--> Data Value: absolute time for checking progress or speed for magnitude

Click on pseudocolor for plot attributes
1. --> Geometry --> Line type: Tubes

Saturday, April 28, 2012

RXTE Analysis

Download Data :

 

Cook Book : 

 

ABC guide :

 

FMI (Fits Master Index) :

Directory structure :

proposal level -> obs level e.g.
P10231 -> 10231-05-01-01

Each level will have a FMI. Copy a FMI from a sub level directory to proposal level. cd out of proposal level and edit FMI :

recofmi P10231 delete=yes



Make Filter file :

xtefilt -s -c -a  -o -p -t 16.0

Example :
xtefilt -s -c -a /usr3/vstr/reji/DEVRAJ/Swift-J1749/appidlist -o 30185-01-01-00 -p /usr3/vstr/reji/DEVRAJ/Swift-J1749/P30185 -f filename -t 16.0

-a path to appidlist. appidlist is created by first typing 
$fhelp xtefilt
copy paste the app ids from the end to a new file named appidlist. It is preferrably kept at proposal level or outside.

-p proposal level dir-path
-o obs dir name (not full path)
-c rewrite old xfl
-s place xfl in stdprod


check filter file : 
fplot offset=yes filter.xfl
choose time as xaxis
choose any appropriate column as y axis (PCU0_ON etc). check list of available columns from
flcol filter.xfl
usual columns :
PCU0_ON, PCU1_ON, PCU2_ON, PCU3_ON, PCU4_ON -> status of PCUs
NUM_PCU_ON -> total number of pcus that were on
ELV -> earth occultation (0 for horizon, +ive for source, -ve for earth). Filter data for angle >= 10 degree.
OFFSET -> stability of pointing. For filter keep offset <= 0.02.
TIME_SINCE_SAA ->  For close to SAA, discard data for faint sources.
ELECTRON# -> filter out when ELECTRON2 > 0.1 for faint source.

In stdprod where .xfl file is located, gti file is produced using make time. e.g. :

To make GTI for all pcus that are one and set limits on elevation and offset :
[devraj@bharani stdprod]$ maketime
Name of FITS file and [ext#][FP_fbd86e8-fbda34f.xfl]
Name of output FITS file[basic.gti]
Selection Expression[elv.gt.10.and.offset.lt.0.02.and.num_pcu_on.gt.0]
Flag, yes if HK format is compact[no]
Column containing HK parameter times[TIME]
PREFR keyword not found, using prefr = 0.5
POSTFR keyword not found, using postfr = 0.5


To make GTI when only 3 pcus are on :
 olegacy [84] [day] ~: maketime
   Name of FITS file and [ext#][] FP_3c7a9f5-3c855c1.xfl
   Name of output FITS file[] basic.gti
   Selection Expression[] elv.gt.10.and.offset.lt.0.02.and.num_pcu_on.eq.3


Additional expression for faint sources :
 (TIME_SINCE_SAA > 30 || TIME_SINCE_SAA < 0.0) && ELECTRON2 < 0.1

To make GTI when 3,4 or 5 PCUs are on :
http://heasarc.nasa.gov/docs/xte/recipes/pcu_combine.html


 Check datatype in PCA directory using 

fkeyprint FS37_fbd86e8-fbd8ea8 datamode
or mymodo (from Tomasso)

Type of event mode data : 
1. E_62mus_.... -> generic event mode
2. Goodxenon mode : GoodXenon1_2s and GoodXenon2_2s

Binner data :

1. SB_...
2. Standard 1f
3. Standard 2f

For GoodXenon :

Combine GoodXenon 1 and 2 files into event files. 
1. Put GoodXenon file names in a file list eg ls *FS37* > filelist
2. Run make_se :

[devraj@bharani pca]$ make_se
Starting up MAKE_SE v.0.20

 > Give name of file containing FITS filelist [fits_files.txt] >
 > Give root for product (output) filenames [event] > 


This creates files like : event_gxn where n is the number of GoodXenon paired files. e.g. event_gx0, event_gx1 etc

Select bitmask

for event modes only.
see :
http://heasarc.nasa.gov/docs/xte/recipes/layers.html

example :

% fselect
Name of FITS file and [ext#][] obs_01_01_gx0 
Name of output FITS file[] obs_01_01_gx0_d0124
Selection Expression[] @bitfile_d0124

sample bitmasks :
http://heasarc.gsfc.nasa.gov/docs/xte/recipes/bitmasks.html#table1

Extract lightcurve by saextract/seextract

saextract -> for binned data (science array)
seextract -> event modes 
see http://heasarc.nasa.gov/docs/xte/abc/data_files.html#array for science data types.

See example saextract here :
http://heasarc.nasa.gov/docs/xte/abc/extracting.html

For input give a single file name or a list of files (max 100) with @filelist 

etc ....

individual layers :
http://heasarc.gsfc.nasa.gov/docs/xte/recipes/layers.html
http://heasarc.gsfc.nasa.gov/docs/xte/abc/pca_issues.html



Plot light curve by lcurve or "fplot offset=yes", entering TIME as the x-axis and RATE[ERROR] as the y-axis.

PHA files for spectral analysis :

run timetrans ( http://heasarc.nasa.gov/docs/xte/abc/extracting.html#time_plot )
to create start and stop times. This creates a file like : peak.tint etc.
The resulting output file containing the converted times can be entered into the extractors (with an @ sign) at the prompt Input time intervals t1-t2, t3-t4 in seconds. 
Rerun seextract/saextract for producing .pha files for spectral analysis.

and example page :
http://heasarc.nasa.gov/docs/xte/abc/extracting.html#event_ex1


Background Estimation :

First copy the relevant background models from the download page :
http://heasarc.nasa.gov/docs/xte/pca_news.html  (see at the end : Important downloads and links)

Steps :
1. Create a new filter file. (rename or move old filter file if necessary)

2. Create a list of standard2 files if there are more than one. Use runpcakackest for multiple files. Use pcabackest for single file at a time.

3. While running pcabackest, input correct standard2 file name, model name etc. See :
http://heasarc.nasa.gov/docs/xte/recipes/pcabackest.html

4. Apply saextrct on background files to produce background light curves and pha files.

5. substract background using lcamath

Create Response matrix


http://heasarc.nasa.gov/docs/xte/recipes/pca_response.html


Dead time

Deadtime should be calculated per PCU: always divide the count rates by the number of PCUs actually on.
http://heasarc.nasa.gov/docs/xte/recipes/pca_deadtime.html


Use XDF for filelist :


To start XDF, type xdf at your system prompt. A window will appear on the screen divided in boxes with accompanying buttons. In broad terms, you start at the top of the window and work downwards, gradually narrowing your data selection criteria by filling the boxes until you produce the file list which appears in the box at the bottom. In more detail:

  1. The first box to fill in is the Path to the directory containing the FMI (FITS Master Index) file - usually the proposal level directory. It is not necessary to type a carriage return when the path name is complete.
  2. Next, use the mouse to activate the Make ObsList button on the top row. This fills the Observations box with one-line summaries of the ObsIds in the top level directory. For each ObsId, the directory name, target name, and time range are listed. At this point you can choose a particular target or time range, though for most GOs this option is not needed.
  3. You select ObsIds themselves by clicking on them with the mouse or by pushing the All button.
  4. The next step is to choose Subsystems from the Subsystems box by clicking on the names of the ones you're interested in.
  5. To see the AppIds/ Configurations of your chosen Subsystem, push the Make AppIdConfigList button on the top row. Select the Appid/Configurations you're interested in from the AppIds/Configurations window.
  6. Finally, when you've completed your choice of AppIds, push the Make FileList button on the top row. The list of corresponding files will appear in the box at the bottom of the screen: if you want to save it, push the Save FileList button on the top row to write out the list to an ASCII file called whatever you put into the File Name window. If no name is specified, it will be called "fits_files.xdf".
Using the @filename convention, the .xdf file may be input to the data reduction software to identify the raw input files.


REX script
http://heasarc.gsfc.nasa.gov/docs/xte/recipes/rex.html


PLOTTING with FTOOLS

Basic PLT cmds  :
https://heasarc.gsfc.nasa.gov/docs/xte/recipes/plotting.html 


FAXBARY:
 command:
faxbary infile=FS_event_gx0_113952e0-11395ce4 outfile=testbary2 orbitfiles=../orbit/FPorbit_Day3344 ra=18.11661111 dec=-29.40833333 refframe="ICRS"

options:
infile=input file name, any event file that you want to analyse. For goods xenon file, give the file obtained after running make_se
outfile=output file name
orbitfiles=orbital ephemeris, always present in the directory orbit in the obsID
ra and dec= coordinates in degrees. Its preferred that correcting pointings are given, based on chandra/xmm pointings obtained from literature. RXTE coordinates in file header may not be accurate
refframe= preferred ICRS as most X-ray data will be compatible with that, FKS being the older version.

Note: latest version of HEASOFT is required as planetary ephemeris files from JPL are searched in standard paths.

Friday, March 30, 2012

MPI

To be used for   MPI_REDUCE, MPI_ALLREDUCE, MPI_REDUCE_SCATTER, and MPI_SCAN
 
 
There are a number of predefined reduction operations for use with MPI_ALLREDUCE, MPI_EXSCAN, MPI_REDUCE, MPI_REDUCE_SCATTER, and MPI_SCAN.
To invoke a predefined operation, place any of the following reductions in variable op.

Operation
Description
MPI_BAND
bitwise AND
MPI_BOR
bitwise OR
MPI_BXOR
bitwise XOR
MPI_LAND
logical AND
MPI_LOR
logical OR
MPI_LXOR
logical XOR
MPI_MAX
maximum value
MPI_MAXLOC
maximum value and location
MPI_MIN
minimum value
MPI_MINLOC
minimum value and location
MPI_PROD
product
MPI_REPLACE
f(a,b) = b (the current value in the target memory is replaced by the value supplied by the origin)
MPI_SUM
sum
Source

MPI_Op_create

int MPI_Op_create(
  MPI_User_function *function,
  int commute,
  MPI_Op *op
);
source

MPI DATA types


Data type
Description
MPI_BYTE
Untyped byte data
MPI_LB
Explicit lower bound marker
MPI_PACKED
Packed data (byte)
MPI_UB
Explicit upper bound marker
Data types for C language bindings
Data type
Description
MPI_CHAR
8-bit character
MPI_DOUBLE
64-bit floating point
MPI_FLOAT
32-bit floating point
MPI_INT
32-bit integer
MPI_LONG
32-bit integer
MPI_LONG_DOUBLE
64-bit floating point
MPI_LONG_LONG
64-bit integer
MPI_LONG_LONG_INT
64-bit integer
MPI_SHORT
16-bit integer
MPI_SIGNED_CHAR
8-bit signed character
MPI_UNSIGNED
32-bit unsigned integer
MPI_UNSIGNED_CHAR
8-bit unsigned character
MPI_UNSIGNED_LONG
32-bit unsigned integer
MPI_UNSIGNED_LONG_LONG
64-bit unsigned integer
MPI_UNSIGNED_SHORT
16-bit unsigned integer
MPI_WCHAR
Wide (16-bit) unsigned character

Example to write a distributed 2D array







Thursday, March 8, 2012

Friday, January 27, 2012

GHATS/XSPEC

gh_version
gh_xte
ghats_all
gh_info
gh_licu,'file',time,rate
gh_plot_licu,time,rate,0,500
ghx,'event.pds',nu,pow,pow_e
gh_plot_power,nu,pow,pow_e
ghx,'event.pds',nu,pow,pow_e,/poisson
ghx,'event.pds',nu,pow,pow_e,/poisson,rms=20.0
 gh_reb,nu,pow,pow_e,2,x,y,ye -> rebin
gh_reb,nu,pow,pow_e,-100,x,y,ye -> logarithmic rebinnin
ghx,'event.pds',nu,pow,pow_e,/poisson,rms=20.0,time=[0,1000] -> time selection
ghx,'event.pds',nu,pow,pow_e,/poisson,rms=20.0,rate=[0,1000] -> rate selection
gh_oplot,... -> oplot
gh_plot_hk,'event.pds'
gh_cross,....... -> for time lags. requires two fft files..etc look up manual


for burst :
tvscl,congrid(dyna[655:680,150:220],512,512)<5

a small dot - > burst oscillation

gh_dyn,dd,time,rate,nu,dyna,frebin=10
tvscl,congrid(dyna,512,512)
tvscl,congrid(dyna(*,1200:1537),512,512)

tvscl,congrid(dyna,512,512)< 5


zmore ****.gz -> preview gz  file
gzip -d * -> zip everything

->untar data file->pca->gzip->ghats->gh_xte


p=pow/c

p_real=pow/(c-b)^2

plot, nu vs nu*p or nu vs nu*nu*p in power density spectra. this enhances the power in higher frequencies

plot nu vs pow to see peak. increase frequency resolution to increase accuracy




ghats to xpsec
 gh_xspec,x,y,ye,'powspec' -> produces powspec.pha and powspec.rmf

xspec fit :
data powspec.pha -> load data
cpd /xw -> open GUI
plot data
setplot energy
XSPEC12>plot data
XSPEC12>plot ldata -> plot logarithmic
XSPEC12>ig 150.-** -> ignore data channel (to remove poisson noise part)
XSPEC12>notice 0.-160. -> include channel
XSPEC12>model loren -> choose model
            6.5       0.05(     0.065)          0          0      1e+06      1e+06
1:lorentz:LineE>0 -1.0 0 0 0 0
            0.1       0.05(     0.001)          0          0         10         20
2:lorentz:Width>0.5
              1       0.01(      0.01)          0          0      1e+24      1e+24
3:lorentz:norm>50

--> negative width means fix variable


XSPEC12>pl -> plot
XSPEC12>renorm -> renormalise data
XSPEC12>addcomp 2 loren -> add another component and use it as secondary fitting component

newp 3 -> change value of parameter 3

del 4 -> delete component
fit -> fit result
err 1 1-12 -> fit with 1 sigma for parameters 1-12

show -> show parameters
save all model -> save model parameters


to see error :
err 1. # -> model number

to load model :
@model.xcm
fit
err 1 #-#

Wednesday, January 11, 2012

Ftools

Example session :
http://heasarc.gsfc.nasa.gov/ftools/users/node13.html#SECTION00063000000000000000

Futils :
http://heasarc.nasa.gov/lheasoft/ftools/futils.html

User's Guide :
http://heasarc.gsfc.nasa.gov/ftools/users/users.html