Init
This commit is contained in:
commit
a0f0371126
166 changed files with 32610 additions and 0 deletions
1
scripts/2df100k.sh
Symbolic link
1
scripts/2df100k.sh
Symbolic link
|
@ -0,0 +1 @@
|
|||
../masks/2df100k/2df100k.sh
|
1
scripts/2df230k.sh
Symbolic link
1
scripts/2df230k.sh
Symbolic link
|
@ -0,0 +1 @@
|
|||
../masks/2df230k/2df230k.sh
|
1
scripts/2qz.sh
Symbolic link
1
scripts/2qz.sh
Symbolic link
|
@ -0,0 +1 @@
|
|||
../masks/2qz10k/2qz.sh
|
1
scripts/call
Symbolic link
1
scripts/call
Symbolic link
|
@ -0,0 +1 @@
|
|||
../masks/healpix/healpix_conversion_scripts/call
|
97
scripts/find_complement.sh
Executable file
97
scripts/find_complement.sh
Executable file
|
@ -0,0 +1,97 @@
|
|||
#! /bin/sh
|
||||
# © M E C Swanson 2008
|
||||
#script to find the complement of a mangle mask
|
||||
#USAGE: find_complement.sh <mask> <complement>
|
||||
#EXAMPLE:find_complement.sh holes.pol complement.pol
|
||||
#input mask can be pixelized beforehand to a fixed resolution
|
||||
#if the mask is complicated, e.g. pixelize -Ps0,8 holes.pol holes_pixelized.pol
|
||||
|
||||
if [ "$MANGLEBINDIR" = "" ] ; then
|
||||
MANGLEBINDIR="../../bin"
|
||||
fi
|
||||
if [ "$MANGLESCRIPTSDIR" = "" ] ; then
|
||||
MANGLESCRIPTSDIR="../../scripts"
|
||||
fi
|
||||
if [ "$MANGLEDATADIR" = "" ] ; then
|
||||
MANGLEDATADIR="../../masks"
|
||||
fi
|
||||
|
||||
mask=$1
|
||||
complement=$2
|
||||
dres=3
|
||||
dscheme="s"
|
||||
|
||||
#check command line arguments
|
||||
if [ "$mask" = "" ] || [ "$complement" = "" ] ; then
|
||||
echo >&2 "ERROR: enter the input and output polygon files as command line arguments."
|
||||
echo >&2 ""
|
||||
echo >&2 "USAGE: find_complement.sh <mask> <complement>"
|
||||
echo >&2 "EXAMPLE:find_complement.sh holes.pol complement.pol"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
head -n 100 $mask > jmaskhead
|
||||
|
||||
#grab pixelization info from input files
|
||||
awk '/pixelization/{print $0}' < jmaskhead > jpix
|
||||
res=`awk '{print substr($2, 1, length($2)-1)}' < jpix`
|
||||
scheme=`awk '{print substr($2, length($2))}' < jpix`
|
||||
rm jpix jmaskhead
|
||||
|
||||
#if input file is unpixelized, pixelize it
|
||||
#if input file is pixelized to a fixed resolution, use it as is.
|
||||
if [ "$res" = "" ]; then
|
||||
res=$dres
|
||||
scheme=$dscheme
|
||||
echo ""
|
||||
echo "Pixelizing $1 ..."
|
||||
$MANGLEBINDIR/pixelize -P${scheme}0,$res $mask jp || exit
|
||||
echo ""
|
||||
elif [ "$res" = -1 ] ; then
|
||||
res=$dres
|
||||
scheme=$dscheme
|
||||
echo "WARNING: cannot take the complement of a mask pixelized adaptively."
|
||||
echo "Pixelizing your mask using a fixed resolution:"
|
||||
echo ""
|
||||
echo "Pixelizing $1 ..."
|
||||
$MANGLEBINDIR/pixelize -P${scheme}0,$res $mask jp || exit
|
||||
echo ""
|
||||
else
|
||||
cp $mask jp
|
||||
fi
|
||||
|
||||
#check for appropriate allsky file, and generate it if it's not there:
|
||||
allsky=$MANGLEDATADIR/allsky/allsky$res$scheme.pol
|
||||
if [ ! -e $allsky ] ; then
|
||||
$MANGLESCRIPTSDIR/make_allsky.sh $res $scheme
|
||||
fi
|
||||
|
||||
#check if input file is snapped
|
||||
snapped=`awk '/snapped/{print $1}' < $mask`
|
||||
|
||||
#if input file isn't snapped, snap it
|
||||
if [ ! "$snapped" = "snapped" ]; then
|
||||
echo "Snapping $1 ..."
|
||||
$MANGLEBINDIR/snap jp jps || exit
|
||||
rm jp
|
||||
else
|
||||
mv jp jps
|
||||
fi
|
||||
|
||||
#set weight of all polygons in mask to zero
|
||||
echo 0 > jw0
|
||||
echo "$MANGLEBINDIR/weight -zjw0 $mask jw"
|
||||
$MANGLEBINDIR/weight -zjw0 jps jw || exit
|
||||
rm jps
|
||||
|
||||
#balkanize the full sky with the zero-weighted mask to find the complement
|
||||
echo "$MANGLEBINDIR/balkanize $allsky jw jb"
|
||||
$MANGLEBINDIR/balkanize $allsky jw jb || exit
|
||||
rm jw
|
||||
|
||||
#unify to get rid of zero weight polygons
|
||||
echo "$MANGLEBINDIR/unify jb $complement"
|
||||
$MANGLEBINDIR/unify jb $complement || exit
|
||||
rm jb
|
||||
|
||||
echo "Complement of $mask written to ${complement}."
|
192
scripts/graphmask.m
Normal file
192
scripts/graphmask.m
Normal file
|
@ -0,0 +1,192 @@
|
|||
function graphmask(infile,outfile,maprange,plottitle,outlines)
|
||||
% © M E C Swanson 2008
|
||||
%function for plotting MANGLE polygon files using the Matlab mapping toolbox.
|
||||
%arguments:
|
||||
%infile=polygon file to be plotted, in 'list' format, i.e.created with poly2poly -ol30 mypolys.pol mypolys.list
|
||||
%outfile=name of eps file to output, or use 'none' if you want to, e.g., put the resulting figure into a subplot.
|
||||
%maprange=[lonmin,lonmax,latmin,latmax] are optional latitude and longitude (Dec and RA)
|
||||
%limits for the mask. If not provided, default is to plot full sky.
|
||||
%title=optional title for the plot
|
||||
%outlines=whether to draw black outlines around polygons. default is no outlines. Use outlines='on' to draw outlines.
|
||||
|
||||
%check if mapping toolbox is installed:
|
||||
if ( ~exist('ispolycw') )
|
||||
fprintf(2, 'To plot mangle masks in Matlab, you must have the mapping\ntoolbox (version 2.0.3 (R14SP1) or later) installed.\n');
|
||||
exitval=1;
|
||||
save('matlabexit.temp','exitval');
|
||||
exit
|
||||
end
|
||||
|
||||
%process input arguments
|
||||
if(nargin<1)
|
||||
error('graphmask requires at least one input argument: the name of the input data file to plot.');
|
||||
end
|
||||
if(nargin==1)
|
||||
outfile='none';
|
||||
maprange=[0 360 -90 90];
|
||||
plottitle='';
|
||||
outlines='';
|
||||
lims=0;
|
||||
end
|
||||
if(nargin==2)
|
||||
maprange=[0 360 -90 90];
|
||||
plottitle='';
|
||||
outlines='';
|
||||
lims=0;
|
||||
end
|
||||
if(nargin==3)
|
||||
plottitle='';
|
||||
outlines='';
|
||||
lims=1;
|
||||
end
|
||||
if(nargin==4)
|
||||
outlines='';
|
||||
lims=1;
|
||||
end
|
||||
if(nargin>=5)
|
||||
lims=1;
|
||||
end
|
||||
if(all(maprange==0))
|
||||
maprange=[0 360 -90 90];
|
||||
lims=0;
|
||||
end
|
||||
%check if mapping toolbox is installed:
|
||||
if (~isnumeric(maprange))
|
||||
fprintf(2, 'ERROR: Non-numeric values used in maprange\n');
|
||||
exitval=1;
|
||||
save('matlabexit.temp','exitval');
|
||||
exit
|
||||
end
|
||||
|
||||
lonmin=maprange(1);
|
||||
lonmax=maprange(2);
|
||||
latmin=maprange(3);
|
||||
latmax=maprange(4);
|
||||
|
||||
%set spacing for tickmarks
|
||||
range=max(latmax-latmin, lonmax-lonmin);
|
||||
avrange=mean([latmax-latmin, lonmax-lonmin]);
|
||||
if(range<15)
|
||||
sp=1;
|
||||
else if (range<30)
|
||||
sp=2;
|
||||
else if (range<90)
|
||||
sp=5;
|
||||
else if (range<150)
|
||||
sp=10;
|
||||
else if (range<300)
|
||||
sp=20;
|
||||
else
|
||||
sp=50;
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
%read in files
|
||||
weightfile=[infile '.weight'];
|
||||
xymat=load(infile);
|
||||
wmat=load(weightfile);
|
||||
fprintf(1,'Done reading files\n');
|
||||
ra=xymat(1:end,1);
|
||||
dec=xymat(1:end,2);
|
||||
weight=wmat(1:end,2);
|
||||
%set up map axes
|
||||
axm=axesm('MapProjection', 'hammer','frame','on','FFaceColor','black','origin',180);
|
||||
|
||||
if (lims)
|
||||
axesm('MapProjection','mercator','frame','on','maplatlimit',[latmin latmax], 'maplonlimit',[lonmin lonmax])
|
||||
setm(gca,'ParallelLabel','on','PLabelLocation',sp,'LabelFormat','none','fontsize',10);
|
||||
tightmap;
|
||||
ax1=gca;
|
||||
ax2=axes('Position',get(ax1,'Position'));
|
||||
axesm('MapProjection','mercator','frame','on','maplatlimit',[latmin latmax], 'maplonlimit',[lonmin lonmax])
|
||||
setm(gca,'FFaceColor','black')
|
||||
else
|
||||
axm=axesm('MapProjection', 'hammer','frame','on','FFaceColor','black','origin',180);
|
||||
end
|
||||
|
||||
%plot polygons in list as patches
|
||||
if (strcmp(outlines,'on'))
|
||||
h=patchesm(dec,ra,'g','Edgecolor','black','Linewidth',0.3);
|
||||
else
|
||||
h=patchesm(dec,ra,'g','Edgecolor','none');
|
||||
end
|
||||
%normalize weights
|
||||
minweight=min(weight);
|
||||
maxweight=max(weight);
|
||||
weight=(weight-minweight)./(maxweight-minweight);
|
||||
%scale weight so that the minimum isn't black unless it's actually zero
|
||||
if(minweight~=0)
|
||||
minscale=.1;
|
||||
zeroscale=minweight-minscale./(1-minscale).*(maxweight-minweight);
|
||||
if(minscale>0 && zeroscale<=0)
|
||||
zeroscale=0;
|
||||
minscale=minweight./maxweight;
|
||||
end
|
||||
weight=(1-minscale).*weight+minscale;
|
||||
else
|
||||
zeroscale=minweight;
|
||||
end
|
||||
|
||||
%set holes (polygons with points wound counterclockwise) to have weight 0
|
||||
ccw=~ispolycw(dec,ra);
|
||||
weight(ccw)=0;
|
||||
%create cell array of colors with each element as grayscale weight
|
||||
color=[weight weight weight];
|
||||
cellcolor=num2cell(color,2);
|
||||
%apply weight colors to patch objects
|
||||
set(h,{'FaceColor'},cellcolor);
|
||||
|
||||
%tweak map display and add labels
|
||||
if (lims)
|
||||
set(gca,'XDir', 'reverse')
|
||||
gridm on;
|
||||
setm(gca,'MeridianLabel','on','MLabelLocation',sp,'MLineLocation',sp,'PLineLocation',sp,'MLabelParallel','south',...
|
||||
'LabelFormat','none', 'MLineLimit',[latmin latmin+.01*avrange],'PLineLimit',[lonmax-.01*avrange, lonmax],...
|
||||
'glinestyle','-','gcolor',[.5 .5 .5],'fontsize',10);
|
||||
tightmap;
|
||||
mlabelzero22pi
|
||||
xlabel('\newline Right Ascension')
|
||||
ylabel('Declination\newline ')
|
||||
else
|
||||
tightmap;
|
||||
xlims=get(gca,'XLim');
|
||||
ylims=get(gca,'YLim');
|
||||
axis([1.01*xlims 1.01*ylims])
|
||||
set(gca,'XDir', 'reverse','XColor',[1 1 1],'YColor',[1 1 1])
|
||||
xlabel('-90^{\circ}','Color','k')
|
||||
ylabel('360^{\circ}','Rotation',0.0,'Color','k','VerticalAlignment','Middle','HorizontalAlignment','Right')
|
||||
ax1=gca;
|
||||
ax2=copyobj(ax1,gcf);
|
||||
set(ax2,'XAxisLocation','top', 'YAxisLocation','right','Color','none','XColor',[1 1 1],'YColor',[1 1 1]);
|
||||
axes(ax2);
|
||||
xlabel('+90^{\circ}','Color','k')
|
||||
ylabel('0^{\circ}','Rotation',0.0,'Color','k','VerticalAlignment','Middle','HorizontalAlignment','Left')
|
||||
end
|
||||
title(plottitle);
|
||||
|
||||
%add colorbar
|
||||
pb=pbaspect;
|
||||
pos1=get(gca,'Position');
|
||||
axes('Position',pos1)
|
||||
axis off
|
||||
colormap('gray')
|
||||
caxis([zeroscale maxweight]);
|
||||
pbaspect(pb);
|
||||
pos1=get(gca,'Position');
|
||||
cbar_handle=colorbar('EastOutside');
|
||||
set(gca,'Position',pos1);
|
||||
|
||||
fprintf(1,'Done making mask image\n');
|
||||
%export image as eps file
|
||||
if(~strcmp(outfile,'none'))
|
||||
set (gcf, 'Color', [1 1 1])
|
||||
if(~lims)
|
||||
set(gcf,'PaperPosition', [-1.75 .75 14 7])
|
||||
end
|
||||
print('-depsc','-r600',outfile);
|
||||
fprintf(1,'Done writing mask image to %s\n',outfile);
|
||||
exit
|
||||
end
|
69
scripts/graphmask.sh
Executable file
69
scripts/graphmask.sh
Executable file
|
@ -0,0 +1,69 @@
|
|||
#!/bin/sh
|
||||
# © M E C Swanson 2008
|
||||
#plot the angular mask described by a polygon file in .list format
|
||||
#using the matlab mapping toolbox
|
||||
#
|
||||
#optional 3rd-6th arguments give the RA and Dec range to plot the mask
|
||||
#if no range is given, the full sky will be plotted
|
||||
#To plot range that includes RA=0, use a negative number for the "low"
|
||||
#end, e.g. for a 10 degree strip covering RA=355 degrees to RA=5 degrees,
|
||||
#use a range of -5 5.
|
||||
#Entering in "0 0 0 0" for the range will also give the default full sky behavior,
|
||||
#which can be used if you also wish to, e.g., enter a title.
|
||||
#
|
||||
#optional 7th argument gives a title for the graph
|
||||
#optional 8th argument turns on drawing black outlines around each polygon
|
||||
#
|
||||
#if specifying the full path to a file (rather than just running in the directory
|
||||
#containing the file you want to plot), put the path in double-quotes as shown below.
|
||||
#
|
||||
#USAGE: graphmask.sh <infile> <outfile> [<ramin> <ramax> <decmin> <decmax>] [<title>] [<outlines>]
|
||||
#EXAMPLES:
|
||||
#fullsky, no outlines: graphmask.sh "dr4/safe0/sdss_dr4safe0_mask.list" "dr4/safe0/sdss_dr4safe0_mask.eps"
|
||||
#defined range, title, no outlines: graphmask.sh sdss_slice.list sdss_slice.eps -45 35 8 21 "SDSS slice"
|
||||
#defined range, no title, outlines: graphmask.sh sdss_slice.list sdss_slice.eps -45 35 8 21 "" on
|
||||
#fullsky, no title, outlines: graphmask.sh sdss_slice.list sdss_slice.eps 0 0 0 0 "" on
|
||||
|
||||
if [ "$MANGLESCRIPTSDIR" = "" ] ; then
|
||||
MANGLESCRIPTSDIR="../../scripts"
|
||||
fi
|
||||
|
||||
if [ $# -eq 2 ]; then
|
||||
if [ -e $1 ]; then
|
||||
if [ -e $2 ]; then
|
||||
rm $2
|
||||
fi
|
||||
matlab -nodisplay -r addpath\(\'$MANGLESCRIPTSDIR\'\)\;graphmask\(\'$1\',\'$2\'\)
|
||||
else
|
||||
echo >&2 "ERROR: file $1 not found."
|
||||
exit 1
|
||||
fi
|
||||
elif [ $# -ge 6 ]; then
|
||||
if [ -e $1 ]; then
|
||||
if [ -e $2 ]; then
|
||||
rm $2
|
||||
fi
|
||||
echo "addpath('$MANGLESCRIPTSDIR'); graphmask('$1','$2',[$3,$4,$5,$6],'$7','$8')" > jgraphtemp.m
|
||||
matlab -nodisplay < jgraphtemp.m
|
||||
rm jgraphtemp.m
|
||||
else
|
||||
echo >&2 "ERROR: file $1 not found."
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo >&2 "USAGE: graphmask.sh <infile> <outfile> [<ramin> <ramax> <decmin> <decmax>] [<title>] [<outlines>]"
|
||||
echo >&2 "EXAMPLES:"
|
||||
echo >&2 "fullsky, no outlines: graphmask.sh \"dr4/safe0/sdss_dr4safe0_mask.list\" \"dr4/safe0/sdss_dr4safe0_mask.eps\""
|
||||
echo >&2 "defined range, title, no outlines: graphmask.sh sdss_slice.list sdss_slice.eps -45 35 8 21 \"SDSS slice\""
|
||||
echo >&2 "defined range, no title, outlines: graphmask.sh sdss_slice.list sdss_slice.eps -45 35 8 21 \"\" on"
|
||||
echo >&2 "fullsky, no title, outlines: graphmask.sh sdss_slice.list sdss_slice.eps 0 0 0 0 \"\" on"
|
||||
exit 1
|
||||
fi
|
||||
if [ -e matlabexit.temp ] || [ ! -e $2 ]; then
|
||||
echo >&2 "ERROR: error in matlab plotting script."
|
||||
if [ -e matlabexit.temp ]; then
|
||||
rm matlabexit.temp
|
||||
fi
|
||||
exit 1
|
||||
fi
|
||||
echo all done!
|
226
scripts/graphmask.sm
Executable file
226
scripts/graphmask.sm
Executable file
|
@ -0,0 +1,226 @@
|
|||
graphmask 28 # © M E C Swanson 2008
|
||||
#An sm script to plot mangle graphics files
|
||||
#first argument: mangle graphics file to read: *.grph
|
||||
#second argument: postscript file for output graph: *.eps
|
||||
#third and fourth arguments: optional range for right ascension to plot
|
||||
# (use 0 0 to plot using range from data)
|
||||
#fifth and sixth arguments: optional range for declination to plot
|
||||
# (use 0 0 to plot with dec range adjusted to give equal scaling on x and y axes,
|
||||
# centered on the range of all the data.)
|
||||
#seventh argument: title of graph: "I am a title"
|
||||
#eighth argument: optional switch: 0 for outlines off, 1 for outlines on (default is 0)
|
||||
#
|
||||
#WARNINGS:
|
||||
# -This script uses the opposite color scheme than the matlab script, i.e.,
|
||||
# weight 1 = black, weight 0 = white
|
||||
# -RA and Dec are treated as linear variables (no spherical projection). This means that
|
||||
# ranges that span RA=0 won't plot properly.
|
||||
# -SM can only plot square eps files, so if you define both RA and Dec range, they should
|
||||
# have the same length, otherwise your plot will appear stretched.
|
||||
# -SM has a line length limit of 1500 characters, which SDSS tends to have no trouble overloading.
|
||||
# If you get an error reading the file, try making your graphics file with lower precision and
|
||||
# fewer points per 2pi, i.e., use poly2poly -og12 -p3 instead of poly2poly -og30.
|
||||
#
|
||||
#USAGE: sm -m $MANGLESCRIPTSDIR/graphmask.sm <infile> <outfile> [<ramin> <ramax>] [<decmin> <decmax>] [<title>] [<outlines>]
|
||||
#EXAMPLES:
|
||||
#default range, no outlines: sm -m $MANGLESCRIPTSDIR/graphmask.sm sdss_slice.grph sdss_slice.eps
|
||||
#defined RA range, outlines: sm -m $MANGLESCRIPTSDIR/graphmask.sm sdss_slice.grph sdss_slice.eps "SDSS slice" 0 35 0 0 1
|
||||
#defined range, no outlines: sm -m $MANGLESCRIPTSDIR/graphmask.sm sdss_slice.grph sdss_slice.eps "SDSS slice" 10 20 10 20
|
||||
#defined range, outlines: sm -m graphmask.sm sdss_slice.grph sdss_slice.eps "SDSS slice" 10 20 10 20 1
|
||||
#
|
||||
data $1
|
||||
device postfilecolour $2
|
||||
#location $gx1 $gx2 $gy1 $(.77*($gx2-$gx1))
|
||||
if($?3) { define title $3 }
|
||||
if($?3 && $?4) {
|
||||
if(!($3==0 && $4==0)){
|
||||
define azmin $3
|
||||
define azmax $4
|
||||
}
|
||||
}
|
||||
if($?5 && $?6) {
|
||||
if(!($5==0 && $6==0)){
|
||||
define elmin $5
|
||||
define elmax $6
|
||||
}
|
||||
}
|
||||
if($?7) { define title $7 }
|
||||
if($?8) { define outlines $8 } else { define outlines 0 }
|
||||
|
||||
define i 0 # i = current line to read in file
|
||||
define in_header 1 # in_header = 1 if reading header of file
|
||||
|
||||
#process header information
|
||||
while{$in_header} {
|
||||
define i ($i+1)
|
||||
read row header $i.s
|
||||
if (header[1]=='polygons'){
|
||||
define npoly (ATOF((header[0])))
|
||||
} else { if (header[0]=='unit'){
|
||||
define unit (header[1])
|
||||
} else { if (header[0]=='graphics'){
|
||||
#we've reached the body of the data file, so move on
|
||||
define in_header 0
|
||||
} else {
|
||||
write standard Unrecognized format in line $i of $1.
|
||||
write standard Please fix the data file and try again.
|
||||
write smerr.temp 1
|
||||
quit
|
||||
}}}
|
||||
|
||||
}
|
||||
|
||||
define i_start $i #i_start = first line of data
|
||||
define polycount 0
|
||||
define first_poly 1
|
||||
|
||||
#process polygon data
|
||||
define numlines ($i_start+2*$npoly-1)
|
||||
while { $i < $numlines } {
|
||||
read row specs $i.s
|
||||
if(specs[0]!='graphics' || dimen(specs)!=12){
|
||||
write standard Formatting error in line $i of $1
|
||||
write standard Your data file probably contains a line over 1500 characters long.
|
||||
write standard Please try to make your data file with shorter lines:
|
||||
write standard i.e., use poly2poly -og10 -p3 instead of poly2poly -og30.
|
||||
write smerr.temp 1
|
||||
quit
|
||||
}
|
||||
set id = ATOF(specs[1])
|
||||
set n_tot = ATOF(specs[3])
|
||||
set edges = ATOF(specs[5])
|
||||
set w = ATOF(specs[7])
|
||||
set midx = ATOF(specs[9])
|
||||
set midy = ATOF(specs[10])
|
||||
|
||||
define numpoints (n_tot[0])
|
||||
|
||||
while{$numpoints>0}{
|
||||
read row polypoints $($i+1)
|
||||
set n = (dimen(polypoints)/2)
|
||||
define numpoints ( $numpoints - n[0])
|
||||
|
||||
#if there are still points to read in for this polygon,
|
||||
#we need to read in another line
|
||||
if($numpoints>0){
|
||||
write standard "extra line for disconnected polygon"
|
||||
define numlines ($numlines+1)
|
||||
}
|
||||
|
||||
#separate list of points in x y x y x y ... format into x and y vectors
|
||||
set ix = 0,2*n[0]-2,2 #even numbers
|
||||
set iy = 1,2*n[0]-1,2 #odd numbers
|
||||
# x = numbers with even list indices (indices start at 0)
|
||||
# y = numbers with odd list indices
|
||||
# tack first point on at end to close the polygon
|
||||
set x=polypoints[ix] CONCAT polypoints[0]
|
||||
set y=polypoints[iy] CONCAT polypoints[1]
|
||||
|
||||
# if polygon is in range to be plotted, add it to plot list
|
||||
if($first_poly){
|
||||
#if this is the first polygon in list, start the list
|
||||
set x_all = x
|
||||
set y_all = y
|
||||
set numpoints = n+1
|
||||
set weight = w
|
||||
define first_poly 0
|
||||
} else {
|
||||
#otherwise, tack this one on to the list
|
||||
set x_all = x_all CONCAT x
|
||||
set y_all = y_all CONCAT y
|
||||
set numpoints = numpoints CONCAT (n+1)
|
||||
set weight = weight CONCAT w
|
||||
}
|
||||
define i ($i+1)
|
||||
define polycount ($polycount+1)
|
||||
}
|
||||
define i ($i+1)
|
||||
}
|
||||
|
||||
limits x_all y_all
|
||||
#adjust limits so the axes have equal scaling
|
||||
if( ($fx2-$fx1)/$nx > ($fy2-$fy1)/$ny ) {
|
||||
define ymid (($fy1+$fy2)/2)
|
||||
define ymin ($ymid - .5*($fx2-$fx1)*$ny/$nx)
|
||||
define ymax ($ymid + .5*($fx2-$fx1)*$ny/$nx)
|
||||
define xmin $fx1
|
||||
define xmax $fx2
|
||||
} else { if( ($fx2-$fx1)/$nx < ($fy2-$fy1)/$ny ) {
|
||||
define xmid (($fx1+$fx2)/2)
|
||||
define xmin ($xmid - .5*($fy2-$fy1)*$nx/$ny)
|
||||
define xmax ($xmid + .5*($fy2-$fy1)*$nx/$ny)
|
||||
define ymin $fy1
|
||||
define ymax $fy2
|
||||
}}
|
||||
limits $xmin $xmax $ymin $ymax
|
||||
|
||||
#if limits have been specified as arguments, use them
|
||||
if($?azmin && $?azmax) {
|
||||
write standard using user-defined limits for RA
|
||||
define scale (($azmax-$azmin)/($xmax-$xmin))
|
||||
define ymid (($fy1+$fy2)/2)
|
||||
define ymin ($ymid - .5*($fy2-$fy1)*$scale)
|
||||
define ymax ($ymid + .5*($fy2-$fy1)*$scale)
|
||||
define xmin $azmin
|
||||
define xmax $azmax
|
||||
if($?elmin && $?elmax) {
|
||||
write standard using user-defined limits for dec
|
||||
define ymin $elmin
|
||||
define ymax $elmax
|
||||
}
|
||||
}
|
||||
limits $xmin $xmax $ymin $ymax
|
||||
|
||||
expand 1.00001
|
||||
ANGLE 0
|
||||
AXIS $fx2 $fx1 0 0 $gx1 $gy1 $($gx2-$gx1) 1 $(0)
|
||||
AXIS $fx2 $fx1 0 0 $gx1 $gy2 $($gx2-$gx1) 0 $(1)
|
||||
ANGLE 90
|
||||
AXIS $fy1 $fy2 0 0 $gx1 $gy1 $($gy2-$gy1) 2 $(1)
|
||||
AXIS $fy1 $fy2 0 0 $gx2 $gy1 $($gy2-$gy1) 0 $(0)
|
||||
ANGLE 0
|
||||
|
||||
#box
|
||||
xlabel Right Ascension ($unit)
|
||||
ylabel Declination ($unit)
|
||||
identification
|
||||
if ($?title) {
|
||||
define titlepos ($gy2+100)
|
||||
relocate ($gx1 $titlepos)
|
||||
putlabel 9 $title
|
||||
}
|
||||
|
||||
define j 0
|
||||
do i=0,$polycount-1 {
|
||||
set k = $j, $j+numpoints[$i]-1
|
||||
set x=x_all[k]
|
||||
set y=y_all[k]
|
||||
#flip so that RA increases from right to left
|
||||
set x = $fx1+$fx2-x
|
||||
define j ($j+numpoints[$i])
|
||||
define gray (int(50+ 200*(1-weight[$i])))
|
||||
ctype = <0 $gray 255> + 256*<0 $gray 255> + 256*256*<0 $gray 255>
|
||||
#check if polygon is clockwise or counterclockwise
|
||||
set ii=0,numpoints[$i]-2
|
||||
set iplus=1,numpoints[$i]-1
|
||||
set cross=((x[ii]*y[iplus])-(x[iplus]*y[ii]))
|
||||
#ishole should be positive if polygon is a hole
|
||||
set ishole=(.5*sum(cross))
|
||||
if($outlines){
|
||||
ctype 0
|
||||
connect x y
|
||||
} else {
|
||||
ctype 1
|
||||
connect x y
|
||||
}
|
||||
if (ishole > 0){
|
||||
ctype 2
|
||||
shade 0 x y
|
||||
} else {
|
||||
ctype 1
|
||||
shade 0 x y
|
||||
}
|
||||
|
||||
}
|
||||
quit
|
||||
#end
|
86
scripts/graphmasksm.sh
Executable file
86
scripts/graphmasksm.sh
Executable file
|
@ -0,0 +1,86 @@
|
|||
#!/bin/sh
|
||||
# © M E C Swanson 2008
|
||||
#plot the angular mask described by a polygon file in graphics format
|
||||
#using sm
|
||||
#
|
||||
#optional 3rd-6th arguments give the RA and Dec range to plot the mask
|
||||
#If no range is given, range will be calculated automatically from the data.
|
||||
#If only an RA range is given, Dec range will be calculated automatically
|
||||
#to give equal scaling on x and y axes, centered on the range of all the data.
|
||||
#
|
||||
#Entering in "0 0 0 0" for the range will also give an automatic range,
|
||||
#which can be used if you also wish to, e.g., enter a title.
|
||||
#Likewise entering "0 0" for the Dec range is equivalent to only specifying an RA range.
|
||||
#
|
||||
#optional 7th argument gives a title for the graph
|
||||
#optional 8th argument turns on drawing black outlines around each polygon
|
||||
#
|
||||
#if specifying the full path to a file (rather than just running in the directory
|
||||
#containing the file you want to plot), put the path in double-quotes as shown below.
|
||||
#
|
||||
#USAGE: graphmasksm.sh <infile> <outfile> [<ramin> <ramax>] [<decmin> <decmax>] [<title>] [<outlines>]
|
||||
#EXAMPLES:
|
||||
#default range, no outlines: graphmasksm.sh "dr4/safe0/sdss_dr4safe0_mask.grph" "dr4/safe0/sdss_dr4safe0_mask.eps"
|
||||
#defined range, title, no outlines: graphmasksm.sh sdss_slice.grph sdss_slice.eps -45 35 8 21 "SDSS slice"
|
||||
#defined range, no title, outlines: graphmasksm.sh sdss_slice.grph sdss_slice.eps -45 35 8 21 " " on
|
||||
#default range, no title, outlines: graphmasksm.sh sdss_slice.grph sdss_slice.eps 0 0 0 0 " " on
|
||||
|
||||
#WARNINGS: (a.k.a., reasons to use the matlab plotting script instead!)
|
||||
# -This script uses the opposite color scheme than the matlab script, i.e.,
|
||||
# weight 1 = black, weight 0 = white
|
||||
# -RA and Dec are treated as linear variables (no spherical projection). This means that
|
||||
# ranges that span RA=0 won't plot properly.
|
||||
# -SM can only plot square eps files, so if you define both RA and Dec range, they should
|
||||
# have the same length, otherwise your plot will appear stretched.
|
||||
# -SM has a line length limit of 1500 characters, which SDSS tends to have no trouble overloading.
|
||||
# If you get an error reading the file, try making your graphics file with lower precision and
|
||||
# fewer points per 2pi, i.e., use poly2poly -og12 -p3 instead of poly2poly -og30.
|
||||
#
|
||||
|
||||
|
||||
if [ "$MANGLESCRIPTSDIR" = "" ] ; then
|
||||
MANGLESCRIPTSDIR="../../scripts"
|
||||
fi
|
||||
|
||||
if [ ! "$7" = "" ] ; then
|
||||
title="\"$7\""
|
||||
else
|
||||
title=""
|
||||
fi
|
||||
|
||||
if [ "$8" = "on" ] ; then
|
||||
outlines=1
|
||||
else
|
||||
outlines=""
|
||||
fi
|
||||
|
||||
if [ $# -ge 2 ]; then
|
||||
if [ -e $1 ]; then
|
||||
echo "Plotting $1 using sm ..."
|
||||
if [ -e $2 ]; then
|
||||
rm $2
|
||||
fi
|
||||
sm -m $MANGLESCRIPTSDIR/graphmask.sm $1 $2 $3 $4 $5 $6 $title $outlines > sm.temp
|
||||
else
|
||||
echo >&2 "ERROR: file $1 not found."
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo >&2 "USAGE: graphmasksm.sh <infile> <outfile> [<ramin> <ramax>] [<decmin> <decmax>] [<title>] [<outlines>]"
|
||||
echo >&2 "EXAMPLES:"
|
||||
echo >&2 "default range, no outlines: graphmasksm.sh \"dr4/safe0/sdss_dr4safe0_mask.grph\" \"dr4/safe0/sdss_dr4safe0_mask.eps\""
|
||||
echo >&2 "defined range, title, no outlines: graphmasksm.sh sdss_slice.grph sdss_slice.eps -45 35 8 21 \"SDSS slice\""
|
||||
echo >&2 "defined range, no title, outlines: graphmasksm.sh sdss_slice.grph sdss_slice.eps -45 35 8 21 \" \" on"
|
||||
echo >&2 "default range, no title, outlines: graphmasksm.sh sdss_slice.grph sdss_slice.eps 0 0 0 0 \" \" on"
|
||||
exit 1
|
||||
fi
|
||||
if [ -e smerr.temp ] || [ ! -e $2 ]; then
|
||||
echo >&2 "ERROR: error in sm plotting script."
|
||||
echo >&2 "See log in sm.temp for more details."
|
||||
if [ -e smerr.temp ]; then
|
||||
rm smerr.temp
|
||||
fi
|
||||
exit 1
|
||||
fi
|
||||
rm sm.temp
|
||||
echo all done!
|
1
scripts/healpixpolys.sh
Symbolic link
1
scripts/healpixpolys.sh
Symbolic link
|
@ -0,0 +1 @@
|
|||
../masks/healpix/healpixpolys.sh
|
1
scripts/healpixrast.sh
Symbolic link
1
scripts/healpixrast.sh
Symbolic link
|
@ -0,0 +1 @@
|
|||
../masks/healpix/healpixrast.sh
|
1
scripts/healpixrast2fits.sh
Symbolic link
1
scripts/healpixrast2fits.sh
Symbolic link
|
@ -0,0 +1 @@
|
|||
../masks/healpix/healpixrast2fits.sh
|
1
scripts/make_allsky.sh
Symbolic link
1
scripts/make_allsky.sh
Symbolic link
|
@ -0,0 +1 @@
|
|||
../masks/allsky/make_allsky.sh
|
146
scripts/make_pixelmaps.sh
Executable file
146
scripts/make_pixelmaps.sh
Executable file
|
@ -0,0 +1,146 @@
|
|||
#!/bin/sh
|
||||
# © M E C Swanson 2008
|
||||
#Script to make pixelmaps of a mask at several resolutions
|
||||
#Pixelmaps give the average value of the mask's weight in each pixel,
|
||||
#using one of mangle's pixelization schemes.
|
||||
#pixelmaps are saved as $inputmask.$res$scheme, e.g. for
|
||||
#the input mask sdss_dr7safe0_res6d.pol, pixelmap files will be
|
||||
#sdss_dr7safe0_res6d.pol.1d, sdss_dr7safe0_res6d.pol.2d, etc.
|
||||
#
|
||||
#if a galaxy file is given, this script also uses polyid to find in which pixels
|
||||
#each galaxy in the list lies. The input galaxy file can have any number of columns,
|
||||
#but the first 2 columns should be the RA and dec.
|
||||
#output galaxy files for each resolution will attach the pixel number to the end of
|
||||
#each line in the galaxy file that lies within a pixel in the pixelmap. The naming
|
||||
#scheme is the same as for the pixelmap files, e.g., for the input galaxy file
|
||||
#sdss_dr7safe0_galdetails1.dat, the output galaxy files will be
|
||||
#sdss_dr7safe0_galdetails1.dat.1d, sdss_dr7safe0_galdetails1.dat.2d, etc.
|
||||
#
|
||||
#By default, this script cuts out any pixels with average weights less than 0.5 for
|
||||
#resolution 1 and average weights less than 0.8 for higher resolutions. To run
|
||||
#the script without these cuts, enter a 0 for the final command line argument.
|
||||
#
|
||||
#USAGE: make_pixelmaps.sh <input mask file> [<input galaxy file>] [<0 to turn cuts off>]
|
||||
#EXAMPLES:
|
||||
#make_pixelmaps.sh sdss_dr7safe0_res6d.pol
|
||||
#make_pixelmaps.sh sdss_dr7safe0_res6d.pol 0
|
||||
#make_pixelmaps.sh sdss_dr7safe0_res6d.pol sdss_dr7safe0_galdetails1.dat
|
||||
#make_pixelmaps.sh sdss_dr7safe0_res6d.pol sdss_dr7safe0_galdetails1.dat 0
|
||||
|
||||
|
||||
if [ "$MANGLEBINDIR" = "" ] ; then
|
||||
MANGLEBINDIR="../../bin"
|
||||
fi
|
||||
if [ "$MANGLESCRIPTSDIR" = "" ] ; then
|
||||
MANGLESCRIPTSDIR="../../scripts"
|
||||
fi
|
||||
if [ "$MANGLEDATADIR" = "" ] ; then
|
||||
MANGLEDATADIR="../../masks"
|
||||
fi
|
||||
|
||||
mask=$1
|
||||
gals=$2
|
||||
cutweights=$3
|
||||
|
||||
#check command line arguments
|
||||
if [ "$mask" = "" ] ; then
|
||||
echo >&2 "ERROR: enter the input polygon and galaxy files as command line arguments."
|
||||
echo >&2 ""
|
||||
echo >&2 "USAGE: make_pixelmaps.sh <input mask file> [<input galaxy file>] [<0 to turn cuts off>]"
|
||||
echo >&2 "EXAMPLES:"
|
||||
echo >&2 "make_pixelmaps.sh sdss_dr7safe0_res6d.pol"
|
||||
echo >&2 "make_pixelmaps.sh sdss_dr7safe0_res6d.pol 0"
|
||||
echo >&2 "make_pixelmaps.sh sdss_dr7safe0_res6d.pol sdss_dr7safe0_galdetails1.dat"
|
||||
echo >&2 "make_pixelmaps.sh sdss_dr7safe0_res6d.pol sdss_dr7safe0_galdetails1.dat 0"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "$gals" == 0 ] ; then
|
||||
cutweights=0
|
||||
gals=
|
||||
fi
|
||||
if [ "$cutweights" = "" ] ; then
|
||||
cutweights=1
|
||||
fi
|
||||
|
||||
dresmax=6
|
||||
dscheme="d"
|
||||
|
||||
head -n 100 $mask > jmaskhead
|
||||
|
||||
#grab pixelization info from input file
|
||||
awk '/pixelization/{print $0}' < jmaskhead > jpix
|
||||
resmax=`awk '{print substr($2, 1, length($2)-1)}' < jpix`
|
||||
scheme=`awk '{print substr($2, length($2))}' < jpix`
|
||||
rm jpix
|
||||
|
||||
#check if input file is snapped and balkanized
|
||||
snapped=`awk '/snapped/{print $1}' < jmaskhead`
|
||||
balkanized=`awk '/balkanized/{print $1}' < jmaskhead`
|
||||
rm jmaskhead
|
||||
|
||||
#if input file is not pixelized, snapped, and balkanized, exit.
|
||||
#if input file is pixelized to a fixed resolution, use it as is.
|
||||
if [ "$resmax" = "" ]; then
|
||||
echo >&2 "ERROR: cannot make pixelmaps of an unpixelized mask."
|
||||
echo >&2 "Pixelize your mask using the pixelize function first."
|
||||
exit 1
|
||||
elif [ "$resmax" = -1 ] ; then
|
||||
resmax=$dresmax
|
||||
echo "WARNING: making pixelmaps of a mask pixelized adaptively."
|
||||
echo "Attempting to make pixelmaps up to resolution $resmax."
|
||||
echo "To guarantee that pixelmaps can be made up to a given resolution,"
|
||||
echo "Pixelize your mask using a fixed resolution <r> by using 'pixelize -P<scheme>0,<r>'."
|
||||
fi
|
||||
|
||||
#if input file isn't snapped, exit
|
||||
if [ ! "$snapped" = "snapped" ]; then
|
||||
echo >&2 "ERROR: cannot make pixelmaps of an unsnapped mask."
|
||||
echo >&2 "Run snap on your mask before running this script,"
|
||||
echo >&2 "or add the 'snapped' keyword to your file if it is already snapped."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
#if input file isn't balkanized, exit
|
||||
if [ ! "$balkanized" = "balkanized" ]; then
|
||||
echo >&2 "ERROR: cannot make pixelmaps of an unbalkanized mask."
|
||||
echo >&2 "Run balkanize on your mask before running this script,"
|
||||
echo >&2 "or add the 'balkanized' keyword to your file if it already consists"
|
||||
echo >&2 "of only non-overlapping polygons."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
for (( res=1; res<=$resmax; res++ ))
|
||||
do
|
||||
|
||||
outmask=$mask.$res$scheme
|
||||
echo "Generating pixelmap for resolution $res ..."
|
||||
$MANGLEBINDIR/pixelmap -P${scheme}0,$res $mask $outmask || exit
|
||||
|
||||
#cut all pixels with weights less than 0.5 for resolution 1 or 0.8 for higher resolutions
|
||||
if [ $cutweights -ne 0 ] ; then
|
||||
if [ $res -le 1 ] ; then
|
||||
weightcut=0.5
|
||||
else
|
||||
weightcut=0.8
|
||||
fi
|
||||
mv $outmask jp
|
||||
$MANGLEBINDIR/poly2poly -j$weightcut jp $outmask || exit
|
||||
echo "Pixels in $outmask have weights in the range defined in make_pixelmaps.sh."
|
||||
echo "To run make_pixelmaps.sh without these cuts, enter a 0 for the last command line argument."
|
||||
echo "EXAMPLE: make_pixelmaps.sh sdss_dr7safe0_res6d.pol sdss_dr7safe0_galdetails1.dat 0"
|
||||
fi
|
||||
|
||||
|
||||
if [ ! "$gals" == "" ] ; then
|
||||
if [ -e "$gals" ] ; then
|
||||
outgals=$gals.$res$scheme
|
||||
$MANGLESCRIPTSDIR/polyid_gals.sh $outmask $gals $outgals
|
||||
else
|
||||
echo >&2 "ERROR: input galaxy file $gals not found!"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
done
|
||||
|
76
scripts/make_setup_script.sh
Executable file
76
scripts/make_setup_script.sh
Executable file
|
@ -0,0 +1,76 @@
|
|||
#! /bin/sh
|
||||
# © M E C Swanson 2008
|
||||
#
|
||||
#script called by wrapper script setup_mangle_environment to set
|
||||
#mangle environment variables
|
||||
#
|
||||
#USAGE: type 'source setup_mangle_environment' in the base mangle directory
|
||||
#If environment is setup correctly, typing
|
||||
#'echo $MANGLEBINDIR; echo $MANGLESCRIPTSDIR; echo $MANGLEDATADIR'
|
||||
#should print out the names of the appropriate directories.
|
||||
#
|
||||
#If the above command doesn't work, try 'source setup_mangle_environment $PWD/'
|
||||
#
|
||||
#
|
||||
#You can also use 'source <MANGLEDIR>setup_mangle_environment <MANGLEDIR>'
|
||||
#where <MANGLEDIR> is the path to the base mangle directory, e.g., /home/username/mangle2.1/
|
||||
#
|
||||
#To automatically set up the mangle environment variables when you start your shell,
|
||||
#add the following line to your .bashrc (or .tcshrc, or .cshrc, or .login, or .profile)
|
||||
#(replace <MANGLEDIR> with the path to your mangle installation):
|
||||
#
|
||||
#source <MANGLEDIR>setup_mangle_environment <MANGLEDIR>
|
||||
|
||||
#If no command line argument is given, assume we're running in the mangle directory
|
||||
#
|
||||
#arguments to make_setup_script.sh are:
|
||||
# $1: 0 if export exists in the environment shell, nonzero otherwise
|
||||
# $2: name of base mangle directory <MANGLEDIR>
|
||||
|
||||
if [ "$2" = "" ]; then
|
||||
MANGLEDIR=$PWD/
|
||||
#otherwise use the path in the first command-line argument as $MANGLEDIR
|
||||
else
|
||||
MANGLEDIR=$2
|
||||
fi
|
||||
MANGLEBINDIR="${MANGLEDIR}bin"
|
||||
MANGLESCRIPTSDIR="${MANGLEDIR}scripts"
|
||||
MANGLEDATADIR="${MANGLEDIR}masks"
|
||||
|
||||
#check to make sure directories exist
|
||||
if [ ! -d $MANGLEBINDIR ]; then
|
||||
echo >&2 "ERROR: The directory $MANGLEBINDIR does not exist"
|
||||
fi
|
||||
if [ ! -d $MANGLESCRIPTSDIR ]; then
|
||||
echo >&2 "ERROR: The directory $MANGLESCRIPTSDIR does not exist"
|
||||
fi
|
||||
if [ ! -d $MANGLEDATADIR ]; then
|
||||
echo >&2 "ERROR: The directory $MANGLEDATADIR does not exist"
|
||||
fi
|
||||
if [ ! -d $MANGLEBINDIR ] || [ ! -d $MANGLESCRIPTSDIR ] || [ ! -d $MANGLEDATADIR ]; then
|
||||
echo >&2 ""
|
||||
echo >&2 "USAGE: type 'source setup_mangle_environment' in the base mangle directory"
|
||||
echo >&2 "Or use 'source <MANGLEDIR>setup_mangle_environment <MANGLEDIR>'"
|
||||
echo >&2 "where <MANGLEDIR> is the path to the base mangle directory,"
|
||||
echo >&2 "e.g., /home/username/mangle2.1/"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
#export environment variables and put bin and scripts directories in the path
|
||||
if [ "$1" = "0" ] ; then
|
||||
cat <<EOF > setup_script
|
||||
export MANGLEBINDIR=$MANGLEBINDIR
|
||||
export MANGLESCRIPTSDIR=$MANGLESCRIPTSDIR
|
||||
export MANGLEDATADIR=$MANGLEDATADIR
|
||||
export PATH=$PATH:$MANGLEBINDIR:$MANGLESCRIPTSDIR
|
||||
EOF
|
||||
else
|
||||
cat <<EOF > setup_script
|
||||
setenv MANGLEBINDIR $MANGLEBINDIR
|
||||
setenv MANGLESCRIPTSDIR $MANGLESCRIPTSDIR
|
||||
setenv MANGLEDATADIR $MANGLEDATADIR
|
||||
setenv PATH $PATH:$MANGLEBINDIR:$MANGLESCRIPTSDIR
|
||||
EOF
|
||||
fi
|
||||
|
||||
|
1
scripts/mangle_sdss.sh
Symbolic link
1
scripts/mangle_sdss.sh
Symbolic link
|
@ -0,0 +1 @@
|
|||
../masks/sdss/mangle_sdss.sh
|
114
scripts/mangle_testsuite.sh
Executable file
114
scripts/mangle_testsuite.sh
Executable file
|
@ -0,0 +1,114 @@
|
|||
#!/bin/sh
|
||||
# © M E C Swanson 2008
|
||||
#
|
||||
#This script tests the mangle installation and creates a tarball of
|
||||
#output files for further examination.
|
||||
#
|
||||
#USAGE: source run_mangle_testsuite > test.log
|
||||
mkdir test
|
||||
|
||||
echo "mangle environment variables are:"
|
||||
echo "MANGLEBINDIR=$MANGLEBINDIR"
|
||||
echo "MANGLESCRIPTSDIR=$MANGLESCRIPTSDIR"
|
||||
echo "MANGLEDATADIR=$MANGLEDATADIR"
|
||||
echo "PATH=$PATH"
|
||||
|
||||
echo "Checking if unformatted fortran files are readable."
|
||||
cd ../masks/2df100k
|
||||
../../bin/weight -z2dF100k ngp_fields.dat jnf || exit
|
||||
../../bin/weight -z2dF100k sgp_fields.dat jnf || exit
|
||||
cd ../2df230k
|
||||
../../bin/weight -z2dF230k ngp_fields.dat jnf || exit
|
||||
../../bin/weight -z2dF230k sgp_fields.dat jnf || exit
|
||||
rm jnf
|
||||
|
||||
echo "Running mangle on 2qz10k mask ..."
|
||||
cd ../2qz10k/
|
||||
./2qz.sh
|
||||
if [ -e 2qz_res4s.eps ]; then
|
||||
mv 2qz_res4s.eps ../../scripts/test
|
||||
if [ -e 2qz_north_res4s.eps ]; then
|
||||
mv 2qz_north_res4s.eps ../../scripts/test
|
||||
fi
|
||||
if [ -e 2qz_south_res4s.eps ]; then
|
||||
mv 2qz_south_res4s.eps ../../scripts/test
|
||||
fi
|
||||
fi
|
||||
mv 2qz_north_res4s.pol 2qz_south_res4s.pol ../../scripts/test
|
||||
|
||||
rm 2qz_*
|
||||
|
||||
samp=dr6
|
||||
echo "Running mangle on slice of SDSS $samp mask ..."
|
||||
cd ../sdss
|
||||
./sdss_quickstart.sh
|
||||
if [ -e sdss_${samp}safe0_slice.eps ]; then
|
||||
mv sdss_${samp}safe0_slice.eps ../../scripts/test
|
||||
elif [ -e sdss_${samp}safe0_slice1.eps ] && [ -e sdss_${samp}safe0_slice2.eps ]; then
|
||||
mv sdss_${samp}safe0_slice1.eps sdss_${samp}safe0_slice2.eps ../../scripts/test
|
||||
else
|
||||
mv sdss_${samp}safe0_slice.pol ../../scripts/test
|
||||
fi
|
||||
rm sdss_${samp}safe0_slice.*
|
||||
|
||||
echo "Trimming 2qz north mask with an icosahedron polygon ..."
|
||||
cd ../../scripts/test
|
||||
cp ../../masks/icosahedron/icosahedron.pol .
|
||||
../../bin/poly2poly -J7,7 icosahedron.pol ico7.pol
|
||||
../../scripts/trim_mask.sh 2qz_north_res4s.pol ico7.pol trimmed_mask.pol
|
||||
rm icosahedron.pol ico7.pol
|
||||
|
||||
echo "Rasterizing 2qz north mask ... "
|
||||
rm ../../masks/healpix/healpix_polys/nside16_p5s.pol
|
||||
../../scripts/healpixrast.sh 2qz_north_res4s.pol 16 rasterized_mask.pol
|
||||
../../scripts/healpixrast2fits.sh 2qz_north_res4s.pol 16 rasterized_mask.fits 16 rasterized_mask.gif
|
||||
../../scripts/call ../../bin/fits2dat_binary.x 1 16 rasterized_mask.fits j2
|
||||
echo healpix_weight 3072 > j1
|
||||
cat j1 j2 > rasterized_mask1.dat
|
||||
rm j1 j2 args.dat
|
||||
../../bin/poly2poly rasterized_mask1.dat rasterized_mask1.pol
|
||||
|
||||
echo "Making pixelmaps of 2qz north mask ..."
|
||||
cp ../../masks/2qz10k/azel.dat jazel
|
||||
tail +2 jazel > azel.dat
|
||||
../../scripts/make_pixelmaps.sh 2qz_north_res4s.pol azel.dat 0
|
||||
rm azel.dat jazel
|
||||
|
||||
if which matlab >/dev/null 2>&1 ; then
|
||||
../../bin/poly2poly -ol30 trimmed_mask.pol trimmed_mask.list
|
||||
../../scripts/graphmask.sh trimmed_mask.list trimmed_mask.eps
|
||||
rm trimmed_mask.list*
|
||||
../../bin/poly2poly -ol30 rasterized_mask.pol rasterized_mask.list
|
||||
../../scripts/graphmask.sh rasterized_mask.list rasterized_mask.eps
|
||||
rm rasterized_mask.list*
|
||||
../../bin/poly2poly -ol30 rasterized_mask1.pol rasterized_mask1.list
|
||||
../../scripts/graphmask.sh rasterized_mask1.list rasterized_mask1.eps
|
||||
rm rasterized_mask1.list*
|
||||
for(( i=1; i<=4; i++ ))
|
||||
do
|
||||
../../bin/poly2poly -ol30 2qz_north_res4s.pol.${i}s jpix.list
|
||||
graphmask.sh jpix.list pixmap${i}.eps
|
||||
rm jpix.list*
|
||||
done
|
||||
elif which sm >/dev/null 2>&1 ; then
|
||||
../../bin/poly2poly -og30 trimmed_mask.pol trimmed_mask.grph
|
||||
../../scripts/graphmasksm.sh trimmed_mask.grph trimmed_mask.eps
|
||||
rm trimmed_mask.grph
|
||||
../../bin/poly2poly -og30 rasterized_mask.pol rasterized_mask.grph
|
||||
../../scripts/graphmasksm.sh rasterized_mask.grph rasterized_mask.eps
|
||||
rm rasterized_mask.grph
|
||||
../../bin/poly2poly -og30 rasterized_mask1.pol rasterized_mask1.grph
|
||||
../../scripts/graphmasksm.sh rasterized_mask1.grph rasterized_mask1.eps
|
||||
rm rasterized_mask1.grph
|
||||
for(( i=1; i<=4; i++ ))
|
||||
do
|
||||
../../bin/poly2poly -og30 2qz_north_res4s.pol.${i}s jpix.grph
|
||||
../../scripts/graphmasksm.sh jpix.grph pixmap${i}.eps
|
||||
rm jpix.grph*
|
||||
done
|
||||
fi
|
||||
cd ..
|
||||
echo >&2 "mangle test suite complete! Output files are in test.tar.gz"
|
||||
mv test.log test
|
||||
tar cfz test.tar.gz test
|
||||
|
1
scripts/plotmap.sh
Symbolic link
1
scripts/plotmap.sh
Symbolic link
|
@ -0,0 +1 @@
|
|||
../masks/healpix/healpix_conversion_scripts/plotmap.sh
|
71
scripts/polyid_gals.sh
Executable file
71
scripts/polyid_gals.sh
Executable file
|
@ -0,0 +1,71 @@
|
|||
#!/bin/sh
|
||||
# © M E C Swanson 2008
|
||||
#
|
||||
#This script uses polyid to find in which polygons in the input mask
|
||||
#each galaxy in the list lies. The input galaxy file can have any number of columns,
|
||||
#but the first 2 columns should be the RA and dec.
|
||||
#output galaxy files for each resolution will attach the polygon number to the end of
|
||||
#each line in the galaxy file.
|
||||
#
|
||||
#By default, galaxies that are not in any polygon in the mask will be cut out of
|
||||
#the output file. To keep all galaxies in the output file, enter a 0 for the final
|
||||
#command line argument.
|
||||
#
|
||||
#USAGE: polyid_gals.sh <input mask file> <input galaxy file> <output galaxy file> [<0 to turn cuts off>]
|
||||
#EXAMPLES:
|
||||
#polyid_gals.sh sdss_dr7safe0_res6d.pol sdss_dr7safe0_galdetails1.dat sdss_dr7safe0_polyidgals_cut.dat
|
||||
#polyid_gals.sh sdss_dr7safe0_res6d.pol sdss_dr7safe0_galdetails1.dat sdss_dr7safe0_polyidgals_uncut.dat 0
|
||||
|
||||
|
||||
if [ "$MANGLEBINDIR" = "" ] ; then
|
||||
MANGLEBINDIR="../../bin"
|
||||
fi
|
||||
if [ "$MANGLESCRIPTSDIR" = "" ] ; then
|
||||
MANGLESCRIPTSDIR="../../scripts"
|
||||
fi
|
||||
if [ "$MANGLEDATADIR" = "" ] ; then
|
||||
MANGLEDATADIR="../../masks"
|
||||
fi
|
||||
|
||||
mask=$1
|
||||
gals=$2
|
||||
outgals=$3
|
||||
cut=$4
|
||||
|
||||
#check command line arguments
|
||||
if [ "$mask" = "" ] || [ "$gals" = "" ] || [ "$outgals" = "" ]; then
|
||||
echo >&2 "ERROR: enter the input polygon file and input and output galaxy files as command line arguments."
|
||||
echo >&2 ""
|
||||
echo >&2 "USAGE: polyid_gals.sh <input mask file> <input galaxy file> <output galaxy file> [<0 to turn cuts off>]"
|
||||
echo >&2 "EXAMPLES:"
|
||||
echo >&2 "polyid_gals.sh sdss_dr7safe0_res6d.pol sdss_dr7safe0_galdetails1.dat sdss_dr7safe0_polyidgals_cut.dat"
|
||||
echo >&2 "polyid_gals.sh sdss_dr7safe0_res6d.pol sdss_dr7safe0_galdetails1.dat sdss_dr7safe0_polyidgals_uncut.dat 0"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "$cut" = "" ] ; then
|
||||
cut=1
|
||||
fi
|
||||
|
||||
#count number of columns in input galaxy file
|
||||
head -n 1 $gals > jgals
|
||||
numfields=`awk '{print NF}' jgals`
|
||||
rm jgals
|
||||
|
||||
#run polyid on galaxy file and assemble output galaxy files with polygon numbers
|
||||
echo "Running polyid to find galaxies from $gals in $mask ... "
|
||||
$MANGLEBINDIR/polyid $mask $gals j1 || exit
|
||||
tail +2 j1 > j2
|
||||
awk '{print $3}' j2 > j3
|
||||
paste $gals j3 > j4
|
||||
if [ $cut -ne 0 ] ; then
|
||||
awk "NF == ($numfields+1) {print \$0}" j4 > $outgals
|
||||
else
|
||||
cp j4 $outgals
|
||||
fi
|
||||
rm j1 j2 j3 j4
|
||||
|
||||
count=`wc -l < $outgals`
|
||||
echo ""
|
||||
echo "wrote $count galaxies to $outgals."
|
||||
|
6
scripts/run_mangle_testsuite
Normal file
6
scripts/run_mangle_testsuite
Normal file
|
@ -0,0 +1,6 @@
|
|||
#USAGE: source run_mangle_testsuite > test.log
|
||||
echo "Setting mangle environment variables"
|
||||
cd ..
|
||||
source setup_mangle_environment $PWD/
|
||||
cd scripts
|
||||
./mangle_testsuite.sh
|
1
scripts/sdss_quickstart.sh
Symbolic link
1
scripts/sdss_quickstart.sh
Symbolic link
|
@ -0,0 +1 @@
|
|||
../masks/sdss/sdss_quickstart.sh
|
140
scripts/trim_mask.sh
Executable file
140
scripts/trim_mask.sh
Executable file
|
@ -0,0 +1,140 @@
|
|||
#! /bin/sh
|
||||
# © M E C Swanson 2008
|
||||
#script to trim a mask so that it only includes polygons in a specified region
|
||||
#USAGE: trim_mask.sh <mask> <trimmer> <outfile> [<pixelization arguments>]
|
||||
#EXAMPLE:trim_mask.sh mask.pol trimmer.pol trimmed_mask.pol
|
||||
# You can also optionally provide arguments to the pixelize function
|
||||
# in the 4th argument:
|
||||
#EXAMPLE: trim_mask.sh mask.pol trimmer.pol trimmed_mask.pol -Ps0,6
|
||||
|
||||
|
||||
if [ "$MANGLEBINDIR" = "" ] ; then
|
||||
MANGLEBINDIR="../../bin"
|
||||
fi
|
||||
if [ "$MANGLESCRIPTSDIR" = "" ] ; then
|
||||
MANGLESCRIPTSDIR="../../scripts"
|
||||
fi
|
||||
if [ "$MANGLEDATADIR" = "" ] ; then
|
||||
MANGLEDATADIR="../../masks"
|
||||
fi
|
||||
|
||||
mask=$1
|
||||
trimmer=$2
|
||||
outfile=$3
|
||||
pixargs=$4
|
||||
|
||||
#check command line arguments:
|
||||
if [ "$mask" = "" ] || [ "$trimmer" = "" ] || [ "$outfile" = "" ] ; then
|
||||
echo >&2 "ERROR: enter the input polygon file, a polygon defining the region you"
|
||||
echo >&2 "want to trim to, and the output polygon file as command line arguments."
|
||||
echo >&2 ""
|
||||
echo >&2 "USAGE: trim_mask.sh <mask> <trimmer> <outfile> [<pixelization arguments>]"
|
||||
echo >&2 "EXAMPLE: trim_mask.sh mask.pol trimmer.pol trimmed_mask.pol"
|
||||
echo >&2 "EXAMPLE w/ optional argument to pixelize: trim_mask.sh mask.pol trimmer.pol trimmed_mask.pol -Ps0,6"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
#if no argument for pixelize is given, pixelize to resolution 6 with the simple scheme:
|
||||
if [ "$pixargs" = "" ] ; then
|
||||
pixargs="-Ps0,6"
|
||||
fi
|
||||
|
||||
head -n 100 $mask > jmaskhead
|
||||
head -n 100 $trimmer > jtrimmerhead
|
||||
|
||||
#grab pixelization info from input files
|
||||
awk '/pixelization/{print $0}' < jmaskhead > jpix
|
||||
res1=`awk '{print substr($2, 1, length($2)-1)}' < jpix`
|
||||
scheme1=`awk '{print substr($2, length($2))}' < jpix`
|
||||
awk '/pixelization/{print $0}' < jtrimmerhead > jpix
|
||||
res2=`awk '{print substr($2, 1, length($2)-1)}' < jpix`
|
||||
scheme2=`awk '{print substr($2, length($2))}' < jpix`
|
||||
rm jpix jmaskhead jtrimmerhead
|
||||
|
||||
#if input files are pixelized, make sure they are consistent:
|
||||
if [ ! "$res1" = "" ] && [ ! "$res2" = "" ] ; then
|
||||
if [ $res1 -eq -1 ] || [ $res2 -eq -1 ] ; then
|
||||
echo >&2 "ERROR: cannot trim a mask pixelized adaptively."
|
||||
echo >&2 "Pixelize both your mask and your trimmer polygon(s) using a fixed resolution,"
|
||||
echo >&2 "e.g. -Ps0,8, and try again."
|
||||
exit 1
|
||||
fi
|
||||
if [ $res1 -ne $res2 ] ; then
|
||||
echo >&2 "ERROR: mask polygons and trimmer polygons must be pixelized to the same resolution."
|
||||
echo >&2 "Pixelize both your mask and your trimmer polygon(s) using a fixed resolution,"
|
||||
echo >&2 "e.g. -Ps0,8, and try again."
|
||||
exit 1
|
||||
fi
|
||||
#if input files are unpixelized, pixelize them:
|
||||
elif [ ! "$res1" = "" ] && [ "$res2" = "" ] ; then
|
||||
if [ $res1 -eq -1 ] ; then
|
||||
echo >&2 "ERROR: cannot trim a mask pixelized adaptively."
|
||||
echo >&2 "Pixelize both your mask and your trimmer polygon(s) using a fixed resolution,"
|
||||
echo >&2 "e.g. -Ps0,8, and try again."
|
||||
exit 1
|
||||
fi
|
||||
echo "$MANGLEBINDIR/pixelize -P${scheme1}0,$res1 $trimmer trimmer_pix"
|
||||
$MANGLEBINDIR/pixelize -P${scheme1}0,$res1 $trimmer trimmer_pix || exit
|
||||
trimmer="trimmer_pix"
|
||||
elif [ "$res1" = "" ] && [ ! "$res2" = "" ] ; then
|
||||
if [ $res2 -eq -1 ] ; then
|
||||
echo >&2 "ERROR: cannot trim a mask pixelized adaptively."
|
||||
echo >&2 "Pixelize both your mask and your trimmer polygon(s) using a fixed resolution,"
|
||||
echo >&2 "e.g. -Ps0,8, and try again."
|
||||
exit 1
|
||||
fi
|
||||
echo "$MANGLEBINDIR/pixelize -P${scheme2}0,$res2 $mask mask_pix"
|
||||
$MANGLEBINDIR/pixelize -P${scheme2}0,$res2 $mask mask_pix || exit
|
||||
mask="mask_pix"
|
||||
else
|
||||
echo "$MANGLEBINDIR/pixelize $pixargs $trimmer trimmer_pix"
|
||||
$MANGLEBINDIR/pixelize $pixargs $trimmer trimmer_pix || exit
|
||||
echo "$MANGLEBINDIR/pixelize $pixargs $mask mask_pix"
|
||||
$MANGLEBINDIR/pixelize $pixargs $mask mask_pix || exit
|
||||
trimmer="trimmer_pix"
|
||||
mask="mask_pix"
|
||||
fi
|
||||
|
||||
#check if input file is snapped
|
||||
snapped=`awk '/snapped/{print $1}' < $mask`
|
||||
|
||||
#if mask file isn't snapped, snap it
|
||||
if [ ! "$snapped" = "snapped" ]; then
|
||||
echo "Snapping $mask ..."
|
||||
mv $mask jp
|
||||
$MANGLEBINDIR/snap jp $mask || exit
|
||||
rm jp
|
||||
fi
|
||||
|
||||
#find the complement of the trimmer polygon
|
||||
echo "$MANGLESCRIPTSDIR/find_complement.sh $trimmer trimmer_comp"
|
||||
$MANGLESCRIPTSDIR/find_complement.sh $trimmer trimmer_comp || exit
|
||||
|
||||
#set the complement to have zero weight
|
||||
echo 0 > jw0
|
||||
echo "$MANGLEBINDIR/weight -zjw0 trimmer_comp jcomp0"
|
||||
$MANGLEBINDIR/weight -zjw0 trimmer_comp jcomp0 || exit
|
||||
rm jw0
|
||||
|
||||
#balkanize the mask with the zero-weight complement, thereby trimming off
|
||||
#everything that does not lie within the trimmer polygon
|
||||
echo "$MANGLEBINDIR/balkanize $mask jcomp0 jb"
|
||||
$MANGLEBINDIR/balkanize $mask jcomp0 jb || exit
|
||||
rm jcomp0
|
||||
|
||||
#unify to get rid of zero weight polygons
|
||||
echo "$MANGLEBINDIR/unify jb $outfile"
|
||||
$MANGLEBINDIR/unify jb $outfile || exit
|
||||
rm jb
|
||||
|
||||
echo "Polygons of $1 trimmed by $2 written to ${outfile}."
|
||||
|
||||
#clean up
|
||||
|
||||
rm trimmer_comp
|
||||
if [ -e trimmer_pix ] ; then
|
||||
rm trimmer_pix
|
||||
fi
|
||||
if [ -e mask_pix ] ; then
|
||||
rm mask_pix
|
||||
fi
|
Loading…
Add table
Add a link
Reference in a new issue