IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 6791


Ignore:
Timestamp:
Apr 5, 2006, 12:46:25 AM (20 years ago)
Author:
eugene
Message:

working on file I/O

Location:
trunk/psastro/src
Files:
4 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/psastro/src/psastro.c

    r5560 r6791  
    33int main (int argc, char **argv) {
    44
     5    psTimerStart ("complete");
     6
    57    psMetadata *header = NULL;
    68
    79    // load configuration information
    8     psMetadata *config = psastroArguments (&argc, argv);
     10    pmConfig *config = psastroArguments (&argc, argv);
    911
    10     // load the input data (cmp file)
    11     psArray *rawstars = psastroReadCMP (&header, argv[2]);
     12    // load input data (config and images (signal, noise, mask)
     13    psastroParseCamera (config);
     14
     15    // perform the astrometric solution
     16    psastroDataLoop (input, config);
    1217
    1318    // simple layout interpretation, basic WCS conversion
     
    2328    psastroWriteCMP (fpa, argv[3]);
    2429
     30    psLogMsg ("psphot", 3, "complete psphot run: %f sec\n", psTimerMark ("complete"));
     31
    2532    psFree (config);
    2633    psFree (fpa);
  • trunk/psastro/src/psastro.h

    r5575 r6791  
    1010# define toTPA toTangentPlane
    1111# define toSky projection
     12
     13// How much of the FPA to load at a time
     14typedef enum {
     15    PP_LOAD_NONE,                       // Don't load anything
     16    PP_LOAD_FPA,                        // Load the entire FPA at once
     17    PP_LOAD_CHIP,                       // Load by chip
     18    PP_LOAD_CELL,                       // Load by cell
     19} ppImageLoadDepth;
     20
     21// Configuration data
     22typedef struct {
     23    psMetadata *site;                   // The site configuration
     24    psMetadata *camera;                 // The camera configuration
     25    psMetadata *recipe;                 // The recipe (i.e., specific setups)
     26    psMetadata *arguments;              // Command-line arguments
     27    psMetadata *options;                // Command-line recipe options
     28    psDB       *database;               // Database handle
     29} ppConfig;
     30
     31// A file to process
     32typedef struct {
     33    char *filename;                     // File name
     34    psFits *fits;                       // The FITS file handle
     35    psMetadata *phu;                    // The FITS header
     36    pmFPA *fpa;                         // The FPA, with pixels and extensions
     37} ppFile;
    1238
    1339bool              pmAstromReadWCS (psPlaneTransform **toFPA, psProjection **toSky, psMetadata *header);
  • trunk/psastro/src/psastroArguments.c

    r5565 r6791  
    11# include "psastro.h"
    2 
    3 static void usage (void);
    4 static void usage_test (void);
    5 
    6 psMetadata *psastroArguments (int *argc, char **argv) {
    7 
    8     unsigned int Nfail;
    9 
    10     // basic pslib options
    11     fprintf (stderr, "starting... %s\n", psLibVersion());
    12     psLogSetFormat ("M");
    13     psLogArguments (argc, argv);
    14     psTraceArguments (argc, argv);
    15 
    16     if (*argc != 4) usage ();
    17 
    18     // load config information
    19     psMetadata *config = psMetadataAlloc ();
    20     config = psMetadataConfigParse (config, &Nfail, argv[1], FALSE);
    21     return (config);
    22 }
     2# include <glob.h>
    233
    244static void usage (void) {
    25     fprintf (stderr, "USAGE: psastro (config) (input) (output)\n");
     5    fprintf (stderr, "USAGE: psastro [-file image(s)] [-list imagelist] (output)\n");
    266    exit (2);
    277}
    288
    29 psMetadata *testArguments (int *argc, char **argv) {
     9pmConfig *psastroArguments (int *argc, char **argv) {
    3010
    31     unsigned int Nfail;
     11    int N;
     12
     13    if (*argc == 1) usage ();
    3214
    3315    // basic pslib options
    34     fprintf (stderr, "starting... %s\n", psLibVersion());
    3516    psLogSetFormat ("M");
    36     psLogArguments (argc, argv);
    37     psTraceArguments (argc, argv);
    3817
    39     if (*argc != 6) usage_test ();
     18    // these other options override the PSPHOT recipe options
     19    psMetadata *options = psMetadataAlloc ();
    4020
    41     // load config information
    42     psMetadata *config = psMetadataAlloc ();
    43     config = psMetadataConfigParse (config, &Nfail, argv[1], FALSE);
     21    // photcode : used in output to supplement header data (argument or recipe?)
     22    if ((N = psArgumentGet (*argc, argv, "-photcode"))) {
     23        psArgumentRemove (N, argc, argv);
     24        psMetadataAddStr (options, PS_LIST_TAIL, "PHOTCODE", PS_META_REPLACE, "", argv[N]);
     25        psArgumentRemove (N, argc, argv);
     26    }
     27
     28    // load config data from default locations
     29    pmConfig *config = pmConfigRead(argc, argv);
     30
     31    // Storage for other command-line arguments
     32    config->arguments = psMetadataAlloc ();
     33
     34    // save these recipe options until we have loaded the options
     35    psMetadataAddPtr (config->arguments, PS_LIST_TAIL, "PSASTRO.OPTIONS",  PS_DATA_METADATA, "", options);
     36
     37    // we load all input files onto a psArray, to be parsed later
     38    psArray *input = psArrayAlloc (16);
     39    input->n = 0;
     40
     41    // load the list of filenames the supplied file (may be a glob: "file*.fits")
     42    if ((N = psArgumentGet (*argc, argv, "-file"))) {
     43        glob_t globList;
     44        psArgumentRemove (N, argc, argv);
     45        globList.gl_offs = 0;
     46        glob (argv[N], 0, NULL, &globList);
     47        for (int i = 0; i < globList.gl_pathc; i++) {
     48            char *filename = psStringCopy (globList.gl_pathv[i]);
     49            psArrayAdd (input, 16, filename);
     50        }
     51        psArgumentRemove (N, argc, argv);
     52    }
     53
     54    // load the list from the supplied text file
     55    if ((N = psArgumentGet (*argc, argv, "-list"))) {
     56        int nItems;
     57        char line[1024]; // XXX limits the list lines to 1024 chars
     58        char word[1024];
     59        char *filename;
     60
     61        psArgumentRemove (N, argc, argv);
     62        FILE *f = fopen (argv[N], "r");
     63        if (f == NULL) {
     64            psAbort ("psphot", "unable to open specified list file");
     65        }
     66        while (fgets (line, 1024, f) != NULL) {
     67            nItems = sscanf (line, "%s", word);
     68            switch (nItems) {
     69              case 0:
     70                break;
     71              case 1:
     72                filename = psStringCopy (word);
     73                psArrayAdd (input, 16, filename);
     74                break;
     75              default:
     76                // rigid format, no comments allowed?
     77                psAbort ("psphot", "error parsing input list file");
     78                break;
     79            }
     80        }
     81        psArgumentRemove (N, argc, argv);
     82    }           
     83    if (input->n < 1) usage ();
     84
     85    // input list gets places as an array on the config->arguements list
     86    psMetadataAddPtr (config->arguments, PS_LIST_TAIL, "INPUT",  PS_DATA_ARRAY, "", input);
     87
     88    if (*argc != 2) usage ();
     89
     90    // output positions is fixed
     91    psMetadataAddStr (config->arguments, PS_LIST_TAIL, "OUTPUT", 0, "", argv[2]);
     92
     93    psTrace(__func__, 1, "Done with psphotArguments...\n");
    4494    return (config);
    4595}
    46 
    47 static void usage_test (void) {
    48     fprintf (stderr, "USAGE: psastro-mktest (config) (cmpfile) (catfile) (rawfile) (reffile)\n");
    49     exit (2);
    50 }
  • trunk/psastro/src/psastroIO.c

    r5565 r6791  
    3636    stars->n = 0;
    3737
    38     // we have fixed bytes / line : use that info
     38
    3939    for (int i = 0; i < nStars; i++) {
    4040        fread (line, 1, 66, f);
Note: See TracChangeset for help on using the changeset viewer.