Main Page | Modules | Data Structures | File List | Data Fields | Globals | Related Pages

extract/source/restore_frame.c

Go to the documentation of this file.
00001 /* === Doxygen Comment ======================================= */
00013 /* =========================================================== */
00014 
00015 #include <IFU_io.h>
00016 #include <IFU_math.h>
00017 #include <snifs.h>
00018 #include <extract.h>
00019 
00020 /* === Doxygen Comment ======================================= */
00032 /* =========================================================== */
00033 
00034 int main(int argc, char **argv)
00035 {
00036   TABLE mask;
00037   IMAGE2D outframe, refframe;
00038   TIGERfile incube;
00039   
00040   char **argval, **arglabel;
00041   char *maskname, *inname, *outname, *refname;
00042   char tmpname[lg_name+1];
00043   char ident[lg_ident+1];
00044 
00045   bool LENS;  
00046 
00047   int i,j;
00048   int no_debug, status;
00049   
00050   /* ##### INTRODUCTION ############################## */
00051   
00052   set_purpose("CCD frame restoration (datacube to CCD)");
00053   set_arglist("-mask none -in none -out none -ref none -lens -1");
00054 
00055   init_snifs("$Name:  $","$Revision: 1.2 $");
00056   init_session(argv,argc,&arglabel,&argval);
00057   
00058   if (DEBUG) {
00059     print_msg("$Id: restore_frame.c,v 1.2 2005/09/15 21:43:14 ycopin Exp $");
00060     print_msg("Compilation: %s, %s",__DATE__,__TIME__);
00061   }
00062 
00063   print_error("WORK IN PROGRESS!!!");
00064   exit_session(ERR_NOIMPL);
00065 
00066   /* ===== Parameters ============================== */
00067   
00068   /* ----- Input ------------------------------ */
00069   
00070   maskname = argval[0];                           /* Input mask */
00071   inname   = argval[1];                       /* Input datacube */
00072   outname  = argval[2];                         /* Output frame */
00073   refname  = argval[3];                      /* Reference frame */
00074   get_argval(4,"%d",&no_debug);      /* Single lens restoration */
00075   LENS     = (no_debug>0);
00076 
00077   /* ----- Output ------------------------------ */
00078 
00079   print_msg("o Input mask: %s",maskname);
00080   print_msg("o Input datacube: %s",inname);
00081   print_msg("o Output frame: %s",outname);
00082   if (LENS) print_msg("o Single lens restoration: #%d",no_debug);
00083 
00084   /* ===== Input cube ============================== */
00085 
00086   print_msg("Opening datacube %s", inname);
00087   if (open_tiger_frame(&incube,inname,"I")<0){
00088     print_error("Cannot open datacube %s",inname);
00089     exit_session(ERR_OPEN);
00090   }
00091 
00092   /* Type/fclass checking to be done latter: more than just an fclass... */
00093 
00094   /* ===== Output frame ============================== */
00095 
00096   /* Check the reference frame name */
00097   if (RD_desc(&incube,CCDFRAME,CHAR,lg_name+1,tmpname) <= 0) {
00098     print_warning("Cannot read original CCD frame in descriptor %s of file %s",
00099                   CCDFRAME,inname);
00100   }
00101   if (strcmp(refname,tmpname)) {
00102     print_warning("Original (%s) and reference (%s) frame names differ.");
00103   }
00104 
00105   /* Open the reference frame header (no need to map the data) */
00106   print_msg("Opening reference frame %s", refname);
00107   if (header_frame(&refframe,refname,"I"))
00108     exit_session(ERR_OPEN);
00109 
00110   /* Create the output frame */
00111   print_msg("Creating restored frame %s [%dx%d]", 
00112             outname, refframe.nx, refframe.ny);
00113   sprintf(ident,"Frame restored from %s",inname);
00114   if (create_frame(&outframe, outname, 
00115                    (int[]){refframe.nx, refframe.ny}, 
00116                    (double[]){refframe.startx, refframe.starty}, 
00117                    (double[]){refframe.stepx, refframe.stepy}, 
00118                    FLOAT, ident, refframe.cunit)) {
00119     print_error("Cannot create restored frame %s",outname);
00120     exit_session(ERR_CREAT);
00121   }
00122   
00123   close_frame(&refframe);
00124 
00125   /* Blank the output frame */
00126   for (j=0; j<outframe.ny; j++) /* Image-oriented loop (i running faster) */
00127     for (i=0; i<outframe.nx; i++) 
00128       WR_frame(&outframe, i,j, 0);
00129 
00130   /* ===== Mask ============================== */
00131 
00132   print_msg("Opening mask %s", maskname);
00133   if ((status = open_mask(maskname,&mask,"I"))) exit_session(status);
00134   handle_select_flag(&mask,'W',NULL);
00135 
00136 
00137 
00138 
00139 
00140 
00141 
00142 
00143 
00144 
00145 
00146 
00147 
00148 
00149 
00150  
00151   exit_session(OK);
00152   return(OK);
00153 }
00154 

Generated on Wed Oct 26 23:59:39 2005 for Snifs by doxygen 1.3.5