/*--------------------------------------------------------------------------- File name : strehl.c Author : Nicolas Devillard Created on : July 30, 1996 Description : Strehl computation over a cube ---------------------------------------------------------------------------*/ /* $Id: strehl.c,v 1.19 2001/07/30 09:58:50 ndevilla Exp $ $Author: ndevilla $ $Date: 2001/07/30 09:58:50 $ $Revision: 1.19 $ */ /*--------------------------------------------------------------------------- Includes ---------------------------------------------------------------------------*/ #include #include #include "eclipse.h" #define PRIMARY_3_60 (3.47) #define SECONDARY_3_60 (1.66) #define LAMBDA_0_3_60 (2.20) #define D_LAMBDA_3_60 (0.30) #define PIXSCALE_3_60 (0.05) /* function just gives the usage for the program */ static void usage(char *pname) ; /* These variables are part of stdlib, to handle command line parsing */ extern char *optarg ; extern int optind ; /*--------------------------------------------------------------------------- Main code ---------------------------------------------------------------------------*/ int main(int argc, char *argv[]) { int c ; strehl_parm spar ; double strehl_ratio ; cube_t * in ; int p ; int cn ; memset(&spar, 0, sizeof(strehl_parm)); spar.m1 = PRIMARY_3_60 ; spar.m2 = SECONDARY_3_60 ; spar.l0 = LAMBDA_0_3_60 ; spar.dl = D_LAMBDA_3_60 ; spar.pscale = PIXSCALE_3_60 ; spar.psf_save = 0 ; spar.psf_filename = "psf1.fits" ; spar.estim_bg = 1 ; if (argc<2) usage(argv[0]) ; /* * Command line parsing by getopt() * See man page for getopt(3c) and implementation in ./pipes */ while ((c = getopt(argc, argv, "Lp:d:l:s:g")) != EOF) switch(c) { /* Standard option: display license (not documented in usage) */ case 'L': eclipse_display_license() ; return 0 ; /* Strehl computation relative options */ /* primary mirror diameter */ case 'p': spar.m1 = (double)atof(optarg) ; break ; /* secondary mirror diameter */ case 'd': spar.m2 = (double)atof(optarg) ; break ; /* Wavelength and filter width */ case 'l': sscanf(optarg, "%lg %lg", &spar.l0, &spar.dl) ; break ; /* Pixel Scale */ case 's': spar.pscale = (double)atof(optarg) ; break ; /* Optional: output the ideal PSF to a FITS file */ case 'g': spar.psf_save = 1 ; break ; default: usage(argv[0]) ; break ; } /* Dis bonjour a la dame */ hello_world(argv[0], "compute strehl ratio") ; /* Get arguments * argc - optind is the number of remaining arguments * argv[optind] is the first argument which is no option * nor option argument. */ if ((argc-optind) < 1) { e_error("missing arguments") ; return -1 ; } /* Initialize eclipse environment */ eclipse_init(); for (cn=optind ; cnlx!=in->ly) { e_error("can only compute strehl on square images: aborting"); cube_del(in); return -1 ; } if (is_power_of_2(in->lx)<0) { e_error("input image size must be a power of 2: aborting"); cube_del(in); return -1 ; } /* Loop on all planes */ printf("File: %s\n", argv[cn]) ; for (p=0 ; pnp; p++) { strehl_ratio = image_compute_strehl(in->plane[p], &spar); printf("plane: %04d\tstrehl %g\n", p+1, strehl_ratio); } cube_del(in); } if (debug_active()) xmemory_status() ; return 0 ; } /* * This function only gives the usage for the program */ static void usage(char *pname) { HelloWorld(pname, "compute strehl ratio") ; printf( "use : %s [parameters] [options] in\n", pname) ; printf( "parameters are:\n" "\t[-p primary_diameter]\n" "\t[-d secondary_diameter]\n" "\t[-l 'lambda0 dlambda']\n" "\t[-s pixelscale]\n" "options are:\n" "\t[-g] to generate 'psf_strehl.fits'\n" "\n\n"); exit(0) ; }