[Swift-commit] r3430 - SwiftApps/Montage
noreply at svn.ci.uchicago.edu
noreply at svn.ci.uchicago.edu
Wed Jul 7 21:19:22 CDT 2010
Author: jonmon
Date: 2010-07-07 21:19:22 -0500 (Wed, 07 Jul 2010)
New Revision: 3430
Added:
SwiftApps/Montage/Background_list.py
Modified:
SwiftApps/Montage/Swift_Montage_Apps.swift
SwiftApps/Montage/Swift_Montage_Batch.swift
SwiftApps/Montage/Swift_Montage_Types.swift
SwiftApps/Montage/makefile
SwiftApps/Montage/montage.sh
SwiftApps/Montage/montage.swift
Log:
o SwiftApps/Montage/Background_list.py
-- Script created to replace the id in the correction table with the image file name. This allows me to run mBackground insteado mBgExec.
o SwiftApps/Montage/Swift_Montage_Apps.swift
o SwiftApps/Montage/Swift_Montage_Batch.swift
o SwiftApps/Montage/Swift_Montage_Types.swift
-- Modifications to finish the mBgBatch swift script. Now all wrappers are implemented needed to run general cases of Montage.
o SwiftApps/Montage/montage.swift
-- Added lines to the script to run the m101 tutorial in Swift.
o SwiftApps/Montage/montage.sh
o SwiftApps/Montage/makefile
-- Minor modifications.
Added: SwiftApps/Montage/Background_list.py
===================================================================
--- SwiftApps/Montage/Background_list.py (rev 0)
+++ SwiftApps/Montage/Background_list.py 2010-07-08 02:19:22 UTC (rev 3430)
@@ -0,0 +1,36 @@
+#!/usr/bin/python
+
+import sys
+#import string
+
+args = sys.argv;
+
+file_tbl_1 = open( args[1], 'r' );
+file_tbl_o = open( args[3], 'w' );
+i = 0
+
+for line_tbl_1 in file_tbl_1:
+
+ l1 = line_tbl_1.split();
+
+ if l1[0] != "|" and l1[0] != "\\datatype":
+
+ file_tbl_2 = open( args[2], 'r' );
+
+ for line_tbl_2 in file_tbl_2:
+
+ l2 = line_tbl_2.split();
+
+ if l2[0] == l1[0]:
+ str_out = "["+str(i)+"].fname = "+l1[len(l1) - 1]+"\n"
+ str_out += "["+str(i)+"].a = "+l2[1]+"\n"
+ str_out += "["+str(i)+"].b = "+l2[2]+"\n"
+ str_out += "["+str(i)+"].c = "+l2[3]+"\n"
+ file_tbl_o.write( str_out )
+ i+=1
+ break
+
+ file_tbl_2.close();
+
+file_tbl_1.close();
+file_tbl_o.close();
Property changes on: SwiftApps/Montage/Background_list.py
___________________________________________________________________
Name: svn:executable
+ *
Modified: SwiftApps/Montage/Swift_Montage_Apps.swift
===================================================================
--- SwiftApps/Montage/Swift_Montage_Apps.swift 2010-07-07 20:20:19 UTC (rev 3429)
+++ SwiftApps/Montage/Swift_Montage_Apps.swift 2010-07-08 02:19:22 UTC (rev 3430)
@@ -1,12 +1,3 @@
-/*! \file Swift_Montage_Apps.swift
- \brief File containing Swift wrappers to basic Montage functions
-
- Each app function is a wrapper to a scalar Montage function.
- Using the word scalar becuase each function takes a single image to
- work on unlike the Swift batch functions.
-*/
-
-
/*! \fn app Image mAdd( Image imgs[], Table img_tbl, MosaicData hdr )
\brief Adds all images in imgs[] into one image file based off the information in img_tbl and hdr.
@@ -32,11 +23,11 @@
\param corr_tbl Correction table containing correction coefficients to be applied
\return mos bg_img corrected image
*/
-( Image bg_img ) mBackground( Image img, Table img_tbl, Table corr_tbl )
+( Image bg_img ) mBackground( Image img, float a, float b, float c )
{
app
{
- mBackground "-n" @img @bg_img @img_tbl @corr_tbl;
+ mBackground "-n" @img @bg_img a b c;
}
}
@@ -133,3 +124,25 @@
mProjectPP "-X" @raw_img @proj_img @hdr;
}
}
+
+
+
+/*----------------------------------------------------------------------------------*/
+/* */
+/* Util Scripts */
+/* */
+/*----------------------------------------------------------------------------------*/
+/*! \fn app Table Background_list( Table imgs_tbl, Table corrs_tbl
+ \brief Generates a list of coefficients that need to be applied and the files to apply them to.
+
+ \param imgs_tbl Table generated by mImgtbl containing information on the set of images
+ \param corrs_tbl Table containing the coefficients and the id of the image to apply them to
+ \return back_tbl Table containing the Image file name and the coefficients that need to be applied to the image. Data is set up so readDatat2 can read the data.
+*/
+( Table back_tbl ) Background_list( Table imgs_tbl, Table corrs_tbl )
+{
+ app
+ {
+ Background_list @imgs_tbl @corrs_tbl @back_tbl;
+ }
+}
Modified: SwiftApps/Montage/Swift_Montage_Batch.swift
===================================================================
--- SwiftApps/Montage/Swift_Montage_Batch.swift 2010-07-07 20:20:19 UTC (rev 3429)
+++ SwiftApps/Montage/Swift_Montage_Batch.swift 2010-07-08 02:19:22 UTC (rev 3430)
@@ -1,54 +1,47 @@
/*! \file Swift_Montage_Batch.swift
- \brief File containing Batch functions for the Swift Montage wrappers
+ \brief File containing Batch functions for the Swift Montage wrappers
- Each batch function allows basic Montage functions to be called on a list of
- images.
+ Each batch function allows basic Montage functions to be called on a list of
+ images.
*/
/*! \fn Image mBgBatch( Image bg_imgs[], Table img_tbl, Table corr_tbl )
- \brief Runs the mBackground wrapper on a list of images in parallel.
+ \brief Runs the mBackground wrapper on a list of images in parallel.
- \param bg_imgs[] The list of images to run the mBackground wrapper on.
- \param img_tbl Table containing information on original images.
- \param corr_tbl Table containing correction coefficients to be applied to the images.
- \return corr_imgs[] List of the corrected images to be added to create image mosaic.
+ \param bg_imgs[] The list of images to run the mBackground wrapper on.
+ \param img_tbl Table containing information on original images.
+ \param corr_tbl Table containing correction coefficients to be applied to the images.
+ \return corr_imgs[] List of the corrected images to be added to create image mosaic.
*/
( Image corr_imgs[] ) mBgBatch( Image bg_imgs[], Table img_tbl, Table corr_tbl )
{
+ Table tmp <"back_tmp.tbl">;
+ tmp = Background_list( img_tbl, corr_tbl );
- /* ImageStruct img_struct_tbl[] <>; */
- /* CorrectStruct correct_stuct_tbl[] <>; */
- /* Image proj_img; */
- /* Image corr_img; */
- /* int A; */
- /* int B; */
- /* int C; */
+ BackgroundStruct back_struct[] = readData2( tmp );
- /* foreach img_tbl_entry, i in img_struct_tbl */
- /* { */
- /* foreach correct_tbl_entry in correct_struct_tbl */
- /* { */
- /* if( img_tbl_entry.cntr == correct_tbl_entry.id ) */
- /* { */
- /* img <single_file_mapper; file = @strcat( @dirname( bg_imgs[0] ), @img_tbl_entry.fname ); */
- /* corr_img <regexp_mapper; source = @img, match = ".*\\\\/(.*)", transform = "corr_dir/corr_\\1">; */
+ foreach background_entry, i in back_struct
+ {
+ Image proj_img <single_file_mapper; file = @strcat( @dirname( bg_imgs[0] )+"/", @background_entry.fname )>;
+ Image corr_img <regexp_mapper; source = @proj_img, match = ".*\\/(.*)", transform = "corr_dir/\\1">;
- /* corr_img = mBackground( img, A, B, C ); */
+ float a = background_entry.a;
+ float b = background_entry.b;
+ float c = background_entry.c;
+ corr_img = mBackground( proj_img, a, b, c );
- /* corr_imgs[ i ] = corr_img; */
- /* } */
- /* } */
- /* } */
+ corr_imgs[ i ] = corr_img;
+ }
}
/*! \fn Image mDiffBatch( Table diff_tbl, MosaicData hdr )
- \brief Runs the mDiff wrapper on a list of images in parallel.
+ \brief Runs the mDiff wrapper on a list of images in parallel.
- \param diff_tbl Table containing a list of images that overlap and must calculate by how much they overlap.
- \param hdr File containing information on how the final mosaic will be set up.
- \return diff_imgs[] List of the difference images that must have correction coefficients calculated.
+ \param diff_tbl Table containing a list of images that overlap and must calculate by how much they overlap.
+ \param hdr File containing information on how the final mosaic will be set up.
+ \return diff_imgs[] List of the difference images that must have correction coefficients calculated.
*/
( Image diff_imgs[] ) mDiffBatch( Table diff_tbl, MosaicData hdr )
{
@@ -56,6 +49,7 @@
foreach d_entry, i in diffs
{
+// tracef("plus: %s \n", @d_entry.plus );
Image proj_1 <single_file_mapper; file = @strcat( "proj_dir/", @d_entry.plus )>;
Image proj_2 <single_file_mapper; file = @strcat( "proj_dir/", @d_entry.minus )>;
@@ -68,11 +62,11 @@
/*! \fn app Table mFitBatch( Table diff_tbl, Image diff_imgs[] )
- \brief Generates a corrected image from imgs and the information from corr_tbl
+ \brief Generates a corrected image from imgs and the information from corr_tbl
- \param diff_tbl
- \param diff_imgs
- \return fits_tbl
+ \param diff_tbl
+ \param diff_imgs
+ \return fits_tbl
*/
( Table fits_tbl ) mFitBatch( Table diff_tbl, Image diff_imgs[] )
{
@@ -84,11 +78,11 @@
/*! \fn Image mProjectPPBatch( Image raw_imgs[], MosaicData hdr )
- \brief Projects the raw images from raw_imgs to a new plane that was declared in hdr.
+ \brief Projects the raw images from raw_imgs to a new plane that was declared in hdr.
- \param raw_imgs[] List of raw images that need to be projected to new plane.
- \param hdr File containing information on how the final mosaic will be set up.
- \return proj_imgs[] List of newly reprojected images.
+ \param raw_imgs[] List of raw images that need to be projected to new plane.
+ \param hdr File containing information on how the final mosaic will be set up.
+ \return proj_imgs[] List of newly reprojected images.
*/
( Image proj_imgs[] ) mProjectPPBatch( Image raw_imgs[], MosaicData hdr )
{
Modified: SwiftApps/Montage/Swift_Montage_Types.swift
===================================================================
--- SwiftApps/Montage/Swift_Montage_Types.swift 2010-07-07 20:20:19 UTC (rev 3429)
+++ SwiftApps/Montage/Swift_Montage_Types.swift 2010-07-08 02:19:22 UTC (rev 3430)
@@ -25,35 +25,26 @@
*/
type JPEG;
-
-/*! \struct CorrectStruct
- \brief Struct to hold data found in the table that is generated from the mBgModel wrapper.
+/*! \struct BackgroundStruct
+ \brief Stuct to hold data found in the tables generated my mImgtbl and mBgModel
*/
-type CorrectStruct
+type BackgroundStruct
{
- int id; /*!< The id referencing which image this entry belongs to */
+ string fname;
+ float a;
+ float b;
+ float c;
};
/*! \struct DiffStruct
\brief Stuct to hold data found in the table that is generated from the mOverlaps wrapper.
-
- \var int cntr1 The id referencing the first image in the difference table.
*/
type DiffStruct
{
- int cntr1; /*!< The id referencing the first image in the difference table. */
- int cntr2; /*!< The id referencing the second image in the difference table. */
- Image plus; /*!< The name of the image referenced by the id number cntr1. */
- Image minus; /*!< The name of the image referenced by the id number cntr2. */
- Image diff; /*!< The name of the difference image that was created by plus and minus. */
+ int cntr1;
+ int cntr2;
+ Image plus;
+ Image minus;
+ Image diff;
};
-
-
-/*! \struct ImageStruct
- \brief Struct to hold data found in the table that is generated from the mImgtbl wrapper.
-*/
-type ImageStruct
-{
- int cntr; /*!< The id referencing which image this entry belongs to */
-};
Modified: SwiftApps/Montage/makefile
===================================================================
--- SwiftApps/Montage/makefile 2010-07-07 20:20:19 UTC (rev 3429)
+++ SwiftApps/Montage/makefile 2010-07-08 02:19:22 UTC (rev 3430)
@@ -7,4 +7,4 @@
swiftrun montage.swift
clean:
- @rm -rvf proj_dir/* diff_dir/* final/* corr_dir/* debug diffs.tbl images-rawdir.tbl images.tbl corrections.tbl fits.tbl stats.tbl
+ @rm -rvf proj_dir/* diff_dir/* final/* corr_dir/* debug diffs.tbl images-rawdir.tbl images.tbl corrections.tbl fits.tbl stats.tbl back_tmp.tbl *.txt
Modified: SwiftApps/Montage/montage.sh
===================================================================
--- SwiftApps/Montage/montage.sh 2010-07-07 20:20:19 UTC (rev 3429)
+++ SwiftApps/Montage/montage.sh 2010-07-08 02:19:22 UTC (rev 3430)
@@ -13,9 +13,9 @@
mDiffExec -p proj_dir -n diffs.tbl template.hdr diff_dir
mFitExec diffs.tbl fits.tbl diff_dir
mBgModel images.tbl fits.tbl corrections.tbl
-# mBgExec -p proj_dir -n images.tbl corrections.tbl corr_dir
-# mAdd -p corr_dir -n images.tbl template.hdr final/mosaic.fits
-# mJPEG -gray final/mosaic.fits 20% 99.98% loglog -out final/mosaic.jpg
+mBgExec -p proj_dir -n images.tbl corrections.tbl corr_dir
+mAdd -p corr_dir -n images.tbl template.hdr final/mosaic.fits
+mJPEG -gray final/mosaic.fits 20% 99.98% loglog -out final/mosaic.jpg
END=$(date +%s)
DIFF=$(( $END - $START ))
Modified: SwiftApps/Montage/montage.swift
===================================================================
--- SwiftApps/Montage/montage.swift 2010-07-07 20:20:19 UTC (rev 3429)
+++ SwiftApps/Montage/montage.swift 2010-07-08 02:19:22 UTC (rev 3430)
@@ -24,10 +24,6 @@
difference_images = mDiffBatch( difference_tbl, template );
fits_images_tbl = mFitBatch( difference_tbl, difference_images );
corrections_tbl = mBgModel( images_tbl, fits_images_tbl );
-
-// Up to here the scripts work.
-
-//corrected_images = mBgBatch( images_tbl, corrections_tbl );
-/* mBgBatch( images_tbl, corrections_tbl ); */
-/* corrected_mos = mAdd( corrected_images, images_tbl, template ); */
-/* corrected_jpg_img = mJPEG( corrected_mos ); */
+corrected_images = mBgBatch( projected_images, images_tbl, corrections_tbl );
+corrected_mos = mAdd( corrected_images, images_tbl, template );
+corrected_jpg_img = mJPEG( corrected_mos );
More information about the Swift-commit
mailing list