Commit b4f68f35 authored by Danny Boxhoorn's avatar Danny Boxhoorn
Browse files

Removed from POST_OMEGAWHITE_VERSION.

parent 5e91941d
bin_PROGRAMS = convolve
convolve_SOURCES = convolve.cpp
AM_CPPFLAGS = -Wall
AM_LDFLAGS = -L../usmlib -L../mupipe_lib -L../dia
LDADD = -lmupipe_lib -ldia -lusmlib -lCCfits -lcfitsio -lltl
convolve_CXXFLAGS = -ftemplate-depth-30
INCLUDES = -I../usmlib/ -I../mupipe_lib/ -I../dia
This diff is collapsed.
bin_PROGRAMS = interpolate
interpolate_SOURCES = interpolate.cpp
AM_CPPFLAGS = -Wall
AM_LDFLAGS = -L../usmlib
LDADD = -lusmlib -lCCfits -lcfitsio -lltl
interpolate_CXXFLAGS = -ftemplate-depth-100
INCLUDES = -I../usmlib
This diff is collapsed.
bin_PROGRAMS = make_mask
make_mask_SOURCES = make_mask.cpp
AM_CPPFLAGS = -Wall
AM_LDFLAGS = -L../usmlib
LDADD = -lusmlib -lCCfits -lcfitsio -lltl
make_mask_CXXFLAGS = -ftemplate-depth-100
INCLUDES = -I../usmlib
#/* -*- C++ -*-
*
* --------------------------------------------------------------------------
* make_mask.cpp, 2007/01/17
* --------------------------------------------------------------------------
*
* Copyright (C) 2000-2007 Johannes Koppenhfer <koppenh@mpe.mpg.de>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
* --------------------------------------------------------------------------
*
*/
#define LTL_RANGE_CHECKING
#undef LTL_RANGE_CHECKING
#include <ltl/config.h>
#include <ltl/marray.h>
#include <ltl/marray_io.h>
#include <ltl/fitsio.h>
#include <ltl/ascio.h>
#include <ltl/wcs.h>
#include <ltl/statistics.h>
#include <ltl/util/option_parser.h>
#include <ltl/util/command_line_reader.h>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <string>
using namespace ltl;
using namespace std;
using namespace util;
struct Parameter
{
string variables;
string output;
string image;
int radius[2];
int yank_columns[110];
int yank_rows[110];
int x_column;
int flux_column;
};
int main( int argc, char **argv )
{
try {
Parameter P;
CommandLineReader COM( argc, argv );
OptionParser OPT( &COM );
try {
OPT.addOption( new StringOption ( "varlist", "", "list of variable stars", 'v', &P.variables ) );
OPT.addOption( new StringOption ( "output", "", "output image filename", 'o', &P.output ) );
OPT.addOption( new StringOption ( "image", "", "reference image filename", 'i', &P.image ) );
OPT.addOption( new IntArrayOption( "radius", "5,10", "masking radius [pixel]", 'r', 2, P.radius ) );
OPT.addOption( new IntOption ( "x_column", "2", "column with x values", 'x', &P.x_column ) );
OPT.addOption( new IntOption ( "flux_column", "5", "column with flux values", 'f', &P.flux_column ) );
OPT.addOption( new IntArrayOption( "rows", "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0", "yank rows", 0, 110, P.yank_rows ) );
OPT.addOption( new IntArrayOption( "columns", "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0", "yank columns", 0, 110, P.yank_columns ) );
}
catch( UException e ) {
cerr << "Parameter exception : " << e.what() << endl;
}
try {
OPT.parseOptions();
}
catch( UException e ) {
string copyright = string( "Copyright (C) 2007- Johannes Koppenhfer <koppenh@mpe.mpg.de>\n" );
cerr << "Caught exception : " << e.what() << endl;
OPT.printUsage( cout );
cerr << copyright << endl;
exit( -1 );
}
if ( P.yank_rows[0] != 0 || P.yank_columns[0] != 0 ) {
FitsHeader header( P.image );
FitsIn bild( P.image );
Region region = bild.getFullRegion();
int length1 = region.getLength(1);
int length2 = region.getLength(2);
FitsOut outfits( P.output.c_str(), header );
outfits.setGeometry( bild.getBitpix(), region );
MArray< float, 2 > map;
bild >> map;
for ( int i=0; i<=109; ++i )
if ( P.yank_columns[i] != 0 )
for ( int y=1; y<=length2; ++y )
map( P.yank_columns[i], y ) = 0.;
for ( int i=0; i<=109; ++i )
if ( P.yank_rows[i] != 0 )
for ( int x=1; x<=length1; ++x )
map( x, P.yank_rows[i] ) = 0.;
outfits << map;
}
else {
if ( P.variables == "" || P.output == "" ) {
string copyright = string( "Copyright (C) 2007- Johannes Koppenhfer <koppenh@mpe.mpg.de>\n" );
OPT.printUsage( cerr );
cerr << copyright << endl;
exit ( -1 );
}
MArray< float, 1 > xpos;
MArray< float, 1 > ypos;
MArray< float, 1 > flux;
MArray< float, 1 > radius;
FitsHeader header( P.image.c_str() );
FitsIn bild( P.image.c_str() );
int size_x = bild.getInt( "NAXIS1 " );
int size_y = bild.getInt( "NAXIS2 " );
int length = 0;
AscFile table( P.variables.c_str() );
if ( P.x_column > 0 ) {
xpos.makeReference( table.readFloatColumn( P.x_column ) );
ypos.makeReference( table.readFloatColumn( P.x_column + 1 ) );
flux.makeReference( table.readFloatColumn( P.flux_column ) );
length = xpos.length(1);
radius.makeReference( MArray< float, 1 > ( length ) );
FitsHeader header( P.image.c_str() );
}
else {
MArray< float, 1 > RA = table.readFloatColumn( -P.x_column );
MArray< float, 1 > DEC = table.readFloatColumn( -P.x_column + 1 );
flux.makeReference( table.readFloatColumn( P.flux_column ) );
length = RA.length(1);
xpos.makeReference( MArray< float, 1 > ( length ) );
ypos.makeReference( MArray< float, 1 > ( length ) );
radius.makeReference( MArray< float, 1 > ( length ) );
FitsHeader header( P.image.c_str() );
FitsCCS ccs( header );
for ( int i = 1; i <= length; ++i ) {
FVector< double, 2 > radec;
radec(1) = RA(i);
radec(2) = DEC(i);
FVector< double, 2 > pix = ccs.radecToPixel( radec );
xpos(i) = pix(1);
ypos(i) = pix(2);
}
}
double flux_min = min( flux );
double flux_max = max( flux );
double flux_diff = flux_max - flux_min;
int radius_diff = P.radius[1] - P.radius[0];
for ( int i = 1; i <= length; ++i )
radius(i) = P.radius[0] + int( radius_diff * ( flux(i) - flux_min ) / flux_diff + 0.5 );
MArray< float, 2 > maskmat( size_x, size_y ); maskmat = 1.;
for ( int i = 1; i <= length; ++i )
for ( int xx = -P.radius[1]; xx <= P.radius[1]; ++xx )
for ( int yy = -P.radius[1]; yy <= P.radius[1]; ++yy ) {
int x = int( xpos(i) + 0.5 );
int y = int( ypos(i) + 0.5 );
if ( pow2( xx ) + pow2( yy ) <= radius(i) * ( radius(i) - 1 ) ) {
int x_new = x + xx;
int y_new = y + yy;
if ( x_new >= 1 && x_new <= size_x && y_new >= 1 && y_new <= size_y )
maskmat( x_new, y_new ) = 0.;
}
}
FitsOut outfits( P.output.c_str(), header );
outfits << maskmat;
}
}
catch ( exception &eww ) {
cout << endl;
cerr << "EXCEPTION: " << eww.what() << endl;
}
return 0;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment