~ubuntu-branches/ubuntu/wily/esorex/wily

« back to all changes in this revision

Viewing changes to src/er_paf.c

  • Committer: Package Import Robot
  • Author(s): Ole Streicher
  • Date: 2014-09-27 22:33:01 UTC
  • mfrom: (1.1.4)
  • Revision ID: package-import@ubuntu.com-20140927223301-s3r9kwa8qcyrnlu4
Tags: 3.11-1
* New upstream version
* Build-depend on libcfitsio-dev instead of libcfitsio3-dev. Closes: #761706
* Update uploader e-mail
* Update standards version to 3.9.6. No changes needed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
109
109
 
110
110
            /* Get PRO CATG of this product */
111
111
            procatg_proplist = cpl_propertylist_load(filename, 0);
112
 
            this_pro_catg = cpl_propertylist_get_string
113
 
                (procatg_proplist, CPL_DFS_PRO_CATG);
 
112
            this_pro_catg = cpl_propertylist_get_string(procatg_proplist, CPL_DFS_PRO_CATG);
 
113
 
114
114
            if(this_pro_catg == NULL)
115
 
                {
116
 
                cpl_msg_error(er_func,"Could not get PRO CATG in file %s",
117
 
                        filename);
118
 
                er_paf_config_delete(paf_configuration);
119
 
                cpl_free(arcfile);
120
 
                paf_err = cpl_error_get_code();
121
 
                return paf_err;
122
 
                }
 
115
            {
 
116
                cpl_msg_error(er_func,"Could not get PRO CATG in file %s",
 
117
                              filename);
 
118
                er_paf_config_delete(paf_configuration);
 
119
                cpl_free(arcfile);
 
120
                paf_err = cpl_error_get_code();
 
121
                return paf_err;
 
122
            }
 
123
 
123
124
            ++idx_paf;
124
125
            cpl_msg_debug(er_func, "Product with PRO CATG=%s", this_pro_catg);
125
126
            cpl_msg_indent_more();
132
133
                int next;
133
134
 
134
135
                cpl_msg_debug(er_func, "Matched with regexp =%s", 
135
 
                              config_item->pro_catg_regexp);
 
136
                              config_item->pro_catg_regexp);
 
137
 
 
138
                /*
 
139
                 *  Try to get ARCFILE from the product itself. If it is not present
 
140
                 *  fall back to retrieving it from the first raw file in the frame
 
141
                 *  set.
 
142
                 */
 
143
 
 
144
                arcfile = cpl_strdup(cpl_propertylist_get_string(procatg_proplist,
 
145
                                                                 "ESO PRO ANCESTOR"));
136
146
                
137
 
                /* Read the ARCFILE keyword from the first raw file */
138
 
                if(arcfile == NULL)
139
 
                    {
140
 
                    arcfile = er_paf_get_arcfile(frames);
141
 
                    if(arcfile == NULL)
142
 
                        {
143
 
                        cpl_msg_error(er_func, "Could not read ARCFILE from raw frames");
144
 
                        er_paf_config_delete(paf_configuration);
145
 
                        return CPL_ERROR_DATA_NOT_FOUND;
146
 
                        }
147
 
                    }
 
147
                if(arcfile == NULL)
 
148
                {
 
149
                    arcfile = er_paf_get_arcfile(frames);
 
150
                    if(arcfile == NULL)
 
151
                    {
 
152
                        cpl_msg_error(er_func,
 
153
                                      "Could not read ARCFILE information from "
 
154
                                      "raw frames");
 
155
                        er_paf_config_delete(paf_configuration);
 
156
                        return CPL_ERROR_DATA_NOT_FOUND;
 
157
                    }
 
158
                }
148
159
 
149
160
                /* Decide what to do depending on number of extensions */
150
161
                next = cpl_frame_get_nextensions(frame);
404
415
        {
405
416
        char * line;
406
417
        line = er_stringarray_get(file_buffer, iline);
 
418
        cx_strstrip(line);
407
419
        if (strcmp(line, "") != 0 && line[0] != '#' )
408
420
            er_stringarray_append(file_stripped, line);
409
421
        }
613
625
    }
614
626
 
615
627
char * er_paf_get_arcfile(const cpl_frameset * frames)
616
 
    {
 
628
{
617
629
    const cpl_frame *  frame;
618
630
    char *             arcfile = NULL;
619
631
    cpl_propertylist * all_keywords;
620
632
    const char *       filename;
621
 
    
 
633
 
622
634
    /* Loop into all the products */
623
 
    frame = cpl_frameset_get_first_const(frames);
624
 
    while (frame != NULL)
625
 
        {
626
 
        if (cpl_frame_get_group(frame) == CPL_FRAME_GROUP_RAW)
627
 
            {
628
 
            filename = cpl_frame_get_filename(frame);
629
 
            all_keywords = cpl_propertylist_load(filename, 0);
630
 
            if(all_keywords == NULL)
631
 
                {
632
 
                cpl_msg_error(er_func,"Could not read the main header of %s",
633
 
                        filename);
634
 
                return NULL;
635
 
                }
636
 
            arcfile = cpl_strdup
637
 
                (cpl_propertylist_get_string(all_keywords, "ARCFILE"));
638
 
            cpl_propertylist_delete(all_keywords);
639
 
            return arcfile;
640
 
            }
641
 
        frame = cpl_frameset_get_next_const(frames);;
642
 
        }
 
635
 
 
636
    cpl_frameset_iterator *it = cpl_frameset_iterator_new(frames);
 
637
 
 
638
    while ((frame = cpl_frameset_iterator_get_const(it)) != NULL)
 
639
    {
 
640
        if (cpl_frame_get_group(frame) == CPL_FRAME_GROUP_RAW)
 
641
        {
 
642
            filename = cpl_frame_get_filename(frame);
 
643
            all_keywords = cpl_propertylist_load(filename, 0);
 
644
            if(all_keywords == NULL)
 
645
            {
 
646
                cpl_frameset_iterator_delete(it);
 
647
                cpl_msg_error(er_func,"Could not read the main header of %s",
 
648
                              filename);
 
649
                return NULL;
 
650
            }
 
651
 
 
652
            const char *_arcfile = cpl_propertylist_get_string(all_keywords,
 
653
                                                               "ESO PRO ANCESTOR");
 
654
 
 
655
            if (!_arcfile && !cpl_propertylist_has(all_keywords, "ESO PRO CATG")) {
 
656
                _arcfile = cpl_propertylist_get_string(all_keywords, "ARCFILE");
 
657
            }
 
658
 
 
659
            if (!_arcfile) {
 
660
                cpl_msg_error(er_func,"Could not get ARCFILE information from "
 
661
                              "the main header of %s", filename);
 
662
                cpl_frameset_iterator_delete(it);
 
663
                cpl_propertylist_delete(all_keywords);
 
664
                return NULL;
 
665
            }
 
666
 
 
667
            arcfile = cpl_strdup(_arcfile);
 
668
 
 
669
            cpl_propertylist_delete(all_keywords);
 
670
            cpl_frameset_iterator_delete(it);
 
671
 
 
672
            return arcfile;
 
673
        }
 
674
 
 
675
        cpl_frameset_iterator_advance(it, 1);
 
676
 
 
677
    }
 
678
 
 
679
    cpl_frameset_iterator_delete(it);
 
680
 
643
681
    cpl_msg_error(er_func,"There are no RAW frames");
644
682
    return arcfile;
645
 
    }
 
683
 
 
684
}
646
685
 
647
686
            
648
687
/**********************************************************************/