gendata.sh
Updated: Oct9,2018

Generate data values using random or gaussian distribution. I also show some simple examples using the unix paste command to generate into data files. This does what gen_noise.sh does, but it is can also generate a noiseless sequence of numbers with fixed steps. This routine is a key part of the higher level script make_fit_data.

 

% gendata.sh --help
Help Information for:  gendata.sh

Usage: gendata.sh gaus 10 10.0 2.0 
arg1 - type of distribution (step,unif,gaus)
arg2 - number of points
arg3 - xmin if rand,  if gaus 
arg4 - xmax if rand, sig if gaus 

I will show: /home/sco/sco/codes/bash/HELP_FILES/gendata.sh.help

Enter any key to roceed with the view of help: 
gendata.sh:
  Generate a set of x(j) data using different recipes: 
    step = progressive numbers with fixed step size 
    unif = randomn numbers from uniform distribution 
    gaus= randomn numbers from  gaussian distribution 

% gendata.sh
Usage: gendata.sh gaus 10 10.0 2.0 
arg1 - type of distribution (step,unif,gaus)
arg2 - number of points
arg3 - xmin if rand,  if gaus 
arg4 - xmax if rand, sig if gaus 

% gendata.sh step 5 1.0 10.0
     1.00000
     3.25000
     5.50000
     7.75000
    10.00000



Example 1

%  gendata.sh gaus 10 10.0 2.0 >a 
%  gendata.sh gaus 10 12.0 3.1 >b 
%  paste a b >final 
%  cat final 
    11.28645        13.99400
     8.29654         9.35964
    11.58986        14.46428
    12.38048        15.68974
    10.41163        12.63803
     8.84070        10.20309
     8.76075        10.07916
     7.77484         8.55101
    10.04731        12.07332
    10.69495        13.07718
 

Example 2

In a more complicated example I wrote a simple script. The script to generate data and some supporting scripts for viewing the results are in: $tdata/T_runs/gendata/ex0. I generate a set of N points (X,Y,Rad) and then transform them with circles_trans.sh. I generate a ds9 regions file with circles_file_ds9.py. In addition, I added some simple timing calls that allow me to time how long it takes to handle different numbers of points



#!/bin/bash

# Generate gaussian point distributions at the 
# Origin (0,0) using sigmas of $2 and $3 
# Rotate the points 30.0 degrees, apply a scale=2.5
# and translate the points to X,Y=1000,1100 

if [ -z "$1" ]
  then
    printf "Usage: ex2.sh 10 100 115  \n"
    printf "arg1 - number of points\n"
    printf "arg2 - sigma for X set \n"
    printf "arg3 - sigma for Y set \n"
    exit
fi
if [ -z "$2" ]
  then
    printf "Usage: ex2.sh 10 100 115  \n"
    printf "arg2 - sigma for X set \n"
    exit
fi
if [ -z "$3" ]
  then
    printf "Usage: ex2.sh 10 100 115  \n"
    printf "arg3 - sigma for Y set \n"
    exit
fi


date >seed 
gendata.sh gaus $1 0.0 $2 >a
sleep 2
gendata.sh gaus $1 0.0 $3 >b
gendata.sh gaus $1 10.0 0.2 >c
echo "# data" >d
paste a b c >e
cat d e >test.1
# Time the translation and region file make
dspit a 1
dsep tstamp.a_1 > Time.Start 
circles_trans.sh test.1 30.0 2.5 1000.0 1100.0 >f.pix
circles_file_ds9.py f.pix red 2 >t1.reg 
dspit a 2
dsep tstamp.a_2 > Time.End 

# clean up 
\rm -f a b c d e f.pix ttt seed  

 
To run 50000 points with this script takes about 4 seconds, and 2 seconds of that is a "sleep 2" task used to prevent correlated random noise. Notice above that I have also added the (dspit,dsep) calls, and these create local time stamp files. Using N=50000 points I see that the transformation and region files are computed in less that 1 second:
 

% make_gauss_noise 50000 100 100 

% cat Time.End Time.Start 
79241
79241

% cat tstamp.* 
Sat Jul  4 22:00:41 UTC 2015
Sat Jul  4 22:00:41 UTC 2015

Clearly, the question of point processing times for the VIRUS applications will probably not be important.

In this TDATA example I also have a couple simple scripts for grabbing an image (S/grab1) and then displaying the results (lookit). In short, the following three commands should give us a ds9 picture:

 

% make_gauss_noise 10000 100 115
% grab1 
% lookit 

% cat lookit 

#!/bin/bash
ds9_open 800 800
imlook n3379_B.fits 50.0
xpaset -p ds9 zoom to fit
cat t1.reg | xpaset ds9 regions -format ds9





Back to SCO CODES page