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

Format in idl

Double precision print in IDL :

Print, n, Format='(F20.10)'

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

Thursday, November 3, 2011

Pdf Merge

gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=finished.pdf file1.pdf file2.pdf


Unless you're very familiar with Ghostscript, that string of commands won't mean much to you. Here's a quick breakdown:
    \t
  • gs -- starts the Ghostscript program
  • \t
  • -dBATCH -- once Ghostscript processes the PDF files, it should exit. If you don't include this option, Ghostscript will just keep running
  • \t
  • -dNOPAUSE -- forces Ghostscript to process each page without pausing for user interaction
  • \t
  • -q -- stops Ghostscript from displaying messages while it works
  • \t
  • -sDEVICE=pdfwrite -- tells Ghostscript to use its built-in PDF writer to process the files
  • \t
  • -sOutputFile=finished.pdf -- tells Ghostscript to save the combined PDF file with the name that you specified

https://www.linux.com/news/software/applications/8229-putting-together-pdf-files

split pdf using GS:

#!/bin/sh
#
# pdfsplit [input.pdf] [first_page] [last_page] [output.pdf] 
#
# Example: pdfsplit big_file.pdf 10 20 pages_ten_to_twenty.pdf
#
# written by: Westley Weimer, Wed Mar 19 17:58:09 EDT 2008
#
# The trick: ghostscript (gs) will do PDF splitting for you, it's just not
# obvious and the required defines are not listed in the manual page. 

if [ $# -lt 4 ] 
then
        echo "Usage: pdfsplit input.pdf first_page last_page output.pdf"
        exit 1
fi
gs -dNOPAUSE -dQUIET -dBATCH -sOutputFile="$4" -dFirstPage=$2 -dLastPage=$3 -sDEVICE=pdfwrite "$1"

gs -dNOPAUSE -dQUIET -dBATCH -sOutputFile=out.pdf -dFirstPage=1 -dLastPage=1 -sDEVICE=pdfwrite Conflict_interest.pdf



https://stackoverflow.com/questions/10228592/splitting-a-pdf-with-ghostscript

Monday, August 8, 2011

Pdf merge using GS

gs -q -sPAPERSIZE=letter -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=output.pdf input1.pdf input2.pdf

Wednesday, March 16, 2011

Movie with ffmpeg/mencoder/image magic

Working options for ffmpeg/mencoder :

To convert PS to png (or jpg) with true color use:

convert -density 300 -type TrueColor -quality 100 file.ps file.png (or jpg)

-type TrueColor suppresses the grey tiles for png. quality is for jpg

For convert to png, to suppress transparent background and have white, use:

convert image.png -background white -alpha remove -alpha off white.png

ffmpeh with offsets
http://ffmpeg.org/ffmpeg-all.html#image2-1

http://hamelot.io/visualization/using-ffmpeg-to-convert-a-set-of-images-into-a-video/


New FFMPEG on mac

ffmpeg  -r 7.5  -i rho.%4d.jpg -vf "scale=trunc(iw/2)*2:trunc(ih/2)*2" -pix_fmt yuv420p -vcodec libx264 rhomovie.mp4


ffmpeg  -r 2.5  -i rho%4d.jpg -vf "scale=trunc(iw/2)*2:trunc(ih/2)*2"  movie.mp4

for quicktime add:  -pix_fmt yuv420p -vcodec libx264 
(https://superuser.com/questions/820134/why-cant-quicktime-play-a-movie-file-encoded-by-ffmpeg)



The divisible by 2 issue with H264
http://stackoverflow.com/questions/20847674/ffmpeg-libx264-height-not-divisible-by-2

For WMV format :
ffmpeg -f image2 -qscale 1 -r 2.5 -b 9600  -i img%4d.jpg movie.wmv


batch convert using mogrify (image magic)

mogrify -format jpg *.png


For JPG :
1. Jayanti's :
mencoder mf://*.jpg -mf w=400:h=400:fps=5:type=jpg -ovc copy -oac copy -o movie.avi

2.my ffmpeg :
ffmpeg -f image2 -qscale 1 -r 5 -b 9600 -y -flags +mv4+aic -trellis 2 -cmp 2 -subcmp 2 -g 300 -pass 1/2 -i img%4d.jpg movie.mp4

3. my mencoder :
mencoder "mf://*.png" -mf fps=5 -o movie.mp4 -ovc lavc -lavcopts vcodec=mpeg4:vhq:trell:vbitrate=9600


For PNG:
1. my mencoder :
mencoder "mf://*.png" -mf fps=5 -o test.avi -ovc lavc -lavcopts vcodec=mpeg4:vhq:trell:vbitrate=9600

2. Jayanti's :
mencoder mf://*.png -mf w=400:h=400:fps=5:type=png -ovc copy -oac copy -o movie.avi


Image Magic mpeg convert :
convert -delay 10 -alpha off *.jpg movie.mp4

-delay {time} Set the time delay (in 1/100th of a second) to pause after drawing the images that are read in or created after this setting has been defined.

You can specify a different scale for the time delay by specifying a 'x' scaling (giving in ticks per second). For example '10x1' is 10, 1 second ticks, while '10x100' is 10, one hundredth of a second ticks.

Basically the 'x' is equivalent to a fraction '/' sign. For example if you specify '1x160' will set a delay that is appropriate for 160 frames per second.

wesite : http://www.imagemagick.org/Usage/anim_basics/




Others :

working cmd line:
ffmpeg -f image2 -qscale 1 -r 5 -b 9600 -y -i img%4d.jpg movie.mp4


mplayer man :

for jpg
mencoder mf://*.jpg -mf w=800:h=600:fps=25:type=jpg -ovc lavc \
-lavcopts vcodec=mpeg4:mbd=2:trell -oac copy -o output.avi

for png
mencoder mf://*.png -mf w=800:h=600:fps=25:type=png -ovc copy -oac copy -o output.avi

website :
http://www.mplayerhq.hu/DOCS/HTML/en/menc-feat-enc-images.html


gary's home page :

mencoder "mf://*.jpg" -mf fps=10 -o test.avi -ovc lavc -lavcopts vcodec=msmpeg4v2:vbitrate=800





ffmpeg working cmdline opts:
ffmpeg -f image2 -qscale 1 -r 5 -b 9600 -y -flags +mv4+aic -trellis 2 -cmp 2 -subcmp 2 -g 300 -pass 1/2 -i img%4d.jpg test.mp4

or

ffmpeg -f image2 -qscale 1 -r 5 -b 9600 -y -i img%4d.jpg movie.mp4




Websites :
http://www.mplayerhq.hu/DOCS/HTML/en/menc-feat-enc-images.html
http://electron.mit.edu/~gsteele/ffmpeg/
http://www.miscdebris.net/blog/2008/04/28/create-a-movie-file-from-single-image-files-png-jpegs/
http://www.idlcoyote.com/graphics_tips/weboutput.php
wesite : http://www.imagemagick.org/Usage/anim_basics/


Other audio/video encoding tid-bits :

http://howto-pages.org/ffmpeg/


Mp4 - mp3 :

ffmpeg -i video.mp4 -f mp3 -ab 192000 -vn music.mp3
 
http://donnieknows.com/blog/mp4-video-mp3-file-using-ffmpeg-ubuntu-910-karmic-koala


Reduce video size:
https://unix.stackexchange.com/questions/28803/how-can-i-reduce-a-videos-size-with-ffmpeg