_trans
  1. Introduction
  2. Sample input files and output
  3. Plotting the results



Introduction

Here I describe a collection of OTW scripts that are designed to apply coordinate transformations to files that specify ds9 regions. I use these primarily for the VIRUS and HET overplotting tools I developed in the 2014-2016 time period. The _trans files take fixed rgions (IFU boxes, text names, lines) and transform them by offsetting about an image center, applying a rotation angle (for example using the parallactic angle), and apply a scale factor (i.e. transform units in microns in the focal plane to units of arcseconds projected on the sky). I'll start with the usage messages and example runs for each type of code. Then I'll give a little more detail about the transformation parameters specified as command line arguments and the format of the input data files. Here are the basic routines:


Usage: cbf_trans.sh IHMP_foot.cbf 0.0 1.9675 426.0 344.1  
arg1 - name of input CBF (XY) file
arg2 - rotation angle in degrees (- for CCW, + for CW)
arg3 - scale (arcsec/pixel)
arg4 - Xo in pixels for new frame 
arg5 - Xo in pixels for new frame 

Usage: circles_trans.sh xyr.arc 27.5 1.35 1000.0 900.1  
arg1 - name of input XYR file
arg2 - rotation angle in degrees (- for CCW, + for CW)
arg3 - multiplicative scale (pixels/units)
arg4 - Xo in pixels for new frame
arg5 - Yo in pixels for new frame

Usage: lsegs_trans.sh file.lsegs 0.0 1.9675 426.0 344.1  
arg1 - name of input line segments file
arg2 - rotation angle in degrees (- for CCW, + for CW)
arg3 - multiplicative scale (pixels/units)
arg4 - Xo in pixels for new frame
arg5 - Yo in pixels for new frame

Usage: text_trans.sh file.text 0.0 1.9675 426.0 344.1  
arg1 - name of input line segments file
arg2 - rotation angle in degrees (- for CCW, + for CW)
arg3 - multiplicative scale (pixels/units)
arg4 - Xo in pixels for new frame
arg5 - Yo in pixels for new frame




Sample input files and output

Here I give a brief explanation of what each routine is plotting and an example of the input file used.


cbf_trans.sh This transforms a set of "closed-bound" line segments. This approach is used to represent some irregularly shaped, but closed, shape (a box, a polygon, a contour set). Each element is a point. All of these points will be connected by a line segment, and the last point will connect to the first point (hence the use of the term "closed boundary"). It is assumed that the point of rotation is X,Y=0,0, and the final rotation point is translated to the coordinatex, X,Y = arg3,arg4 (on the command line). Each point is expressed with two numbers: X1,Y1. Here is a sample:
% cat cbf_example1.dat  
# Closed boundary - example 1
# linear units: arcseconds 
# data
 988 1097
1044 1085
1081 1038
1075  982
1027  965
 940  986
 896 1045
 907 1107

Now I rotate this set by 10deg, with no scale change (arg2=PS=1.0), 
about the rotation point X,Y=0.0. I then translate the rotation 
point to X,Y=10,20:

% cbf_trans.sh cbf_example1.dat 10.0 1.0 10.0 20.0 
    1173.482      928.770
    1226.548      907.228
    1254.824      854.517
    1239.191      800.409
    1188.968      792.003
    1106.936      827.791
    1073.850      893.535
    1095.449      952.683

circles_trans.sh This transforms a set of independent circle regions. Each element is a circle that is expressed with three numbers: X1,Y1,radius. It is assumed that the point of rotation is X,Y=0,0, and the final rotation point is translated to the coordinatex, X,Y = arg3,arg4 (on the command line). Here is a sample:
% cat circles_example1.dat  
# circles - example 1
# linear units: arcseconds 
# data
 988 1097 20
1044 1085 20.5
1081 1038 12
1075  982 15
1027  965 20
 940  986 20
 896 1045 20
 907 1107 20

Now I rotate this set by 10deg, with no scale change (arg2=PS=1.0),
about the rotation point X,Y=0.0. I then translate the rotation
point to X,Y=10,20:

% circles_trans.sh circles_example1.dat 10.0 1.0 10.0 20.0
    1173.482      928.770       20.000
    1226.548      907.228       20.500
    1254.824      854.517       12.000
    1239.191      800.409       15.000
    1188.968      792.003       20.000
    1106.936      827.791       20.000
    1073.850      893.535       20.000
    1095.449      952.683       20.000


lsegs_trans.sh This transforms a set of independent line segments. Each element is a line segment that is expressed with four numbers: X1,Y1,X2,Y2. It is assumed that the point of rotation is X,Y=0,0, and the final rotation point is translated to the coordinatex, X,Y = arg3,arg4 (on the command line). Here is a sample:
% cat lsegs_example1.dat  
# IFU line segments
# linear units: arcseconds
# data
     225.000      425.000      225.000      475.000
     225.000      475.000      275.000      475.000
     275.000      475.000      275.000      425.000
     275.000      425.000      225.000      425.000
     125.000      425.000      125.000      475.000
     125.000      475.000      175.000      475.000
     175.000      475.000      175.000      425.000
     175.000      425.000      125.000      425.000

Now I rotate this set by 10deg, with no scale change (arg2=PS=1.0),
about the rotation point X,Y=0.0. I then translate the rotation
point to X,Y=10,20:

% lsegs_trans.sh lsegs_example1.dat 10.0 1.0 10.0 20.0
     305.382      399.472      314.065      448.713
     314.065      448.713      363.305      440.030
     363.305      440.030      354.623      390.790
     354.623      390.790      305.382      399.472
     206.901      416.837      215.584      466.078
     215.584      466.078      264.824      457.395
     264.824      457.395      256.142      408.155
     256.142      408.155      206.901      416.837

text_trans.sh This transforms a set of independent text strings. Each element is an X,Y location (line1) and a string (line2). It is assumed that the point of rotation is X,Y=0,0, and the final rotation point is translated to the coordinatex, X,Y = arg3,arg4 (on the command line). Here is a sample:
% cat text_example1.dat  
% cat text_example1.dat
# IFU text names
# linear units: arcseconds
# data
     250.000      450.000
030
     150.000      450.000
040
      50.000      450.000
025
     250.000      -50.000
057

Now I rotate this set by 10deg, with no scale change (arg2=PS=1.0),
about the rotation point X,Y=0.0. I then translate the rotation
point to X,Y=10,20:

% text_trans.sh text_example1.dat 10.0 1.0 10.0 20.0
     334.344      419.751   030       
     235.863      437.116   040       
     137.382      454.481   025       
     247.520      -72.652   057      



Plotting the results

The *_trans.sh results all go to standard out. When I use these in a script I generally direct the output to a file (e.g. Blah.pix). Then I feed this file to the appropriete (usually python) code that generates the ds9 regions file. Then I use a simple xpa command to overplot the regions. Below are examples pulled from my gstar script. The script assume I will have a file prepared named "probe.gc1" that gives the Telecen_X,Telecen_Y of the gc1 probe. The "gprobes.sh" converts these Telecen_X,Telecen_Y to units of arcseconds on the sky (written to gprobes.circles and gprobes.text). Here is how I plot the results:

 

if [ -e "probe.gc1" ]
then
# Make the circle/text file, transform it, and display it
 read xo yo pnamo < probe.gc1
 gprobes.sh $xo $yo gc1
 circles_trans.sh gprobes.circles $rotang $ps $Xihmp_dss $Yihmp_dss > D.pix
 circles_file_ds9.py D.pix blue $pall >> gco.reg
 text_trans.sh gprobes.text $rotang $ps $Xihmp_dss $Yihmp_dss > F.pix
 text_file_ds9.py F.pix red $textsize > text.reg
 cat text.reg | xpaset ds9 regions -format ds9
fi
 



Back to SCO CODES page