32 #include "muse_table.h" 34 #include "muse_pfits.h" 35 #include "muse_utils.h" 85 cpl_table_delete(aTable->
table);
86 cpl_propertylist_delete(aTable->
header);
108 cpl_ensure(aFilename, CPL_ERROR_NULL_INPUT, NULL);
113 if (extension <= 0) {
115 cpl_msg_debug(__func__,
"Didn't find a specific extension for IFU %hhu, " 116 "will just use the first one.", aIFU);
121 cpl_errorstate state = cpl_errorstate_get();
123 table->
table = cpl_table_load(aFilename, extension, 1);
124 if (!cpl_errorstate_is_equal(state) || !table->
table ||
125 !cpl_table_get_nrow(table->
table)) {
126 cpl_msg_info(__func__,
"Loading table from file \"%s\" (ext %d) failed: %s",
127 aFilename, extension, cpl_error_get_message());
133 table->
header = cpl_propertylist_load(aFilename, 0);
136 cpl_propertylist *hext = cpl_propertylist_load(aFilename, extension);
137 state = cpl_errorstate_get();
139 char *extname = NULL;
140 if (en && cpl_errorstate_is_equal(state)) {
141 extname = cpl_sprintf(
"[%s]", en);
143 if (!cpl_propertylist_has(table->
header,
"EXTNAME")) {
144 cpl_propertylist_append_string(table->
header,
"EXTNAME", en);
145 cpl_propertylist_set_comment(table->
header,
"EXTNAME",
146 cpl_propertylist_get_comment(hext,
"EXTNAME"));
149 cpl_errorstate_set(state);
150 extname = cpl_sprintf(
"%c",
'\0');
152 cpl_msg_info(__func__,
"Loaded table from file \"%s%s\" (ext %d).", aFilename,
155 cpl_propertylist_delete(hext);
175 cpl_ensure_code(aTable && aFilename, CPL_ERROR_NULL_INPUT);
177 cpl_error_code rc = cpl_table_save(aTable->
table, aTable->
header,
178 NULL, aFilename, CPL_IO_CREATE);
const char * muse_pfits_get_extname(const cpl_propertylist *aHeaders)
find out the extension name
int muse_utils_get_extension_for_ifu(const char *aFilename, unsigned char aIFU)
Return extension number that corresponds to this IFU/channel number.
cpl_error_code muse_table_save(muse_table *aTable, const char *aFilename)
Save the data and the FITS headers of a MUSE table to a file.
muse_table * muse_table_new(void)
Allocate memory for a new muse_table object.
cpl_table * table
The table.
Structure to store a table together with a property list.
void muse_table_delete(muse_table *aTable)
Deallocate memory associated to a muse_table object.
cpl_propertylist * header
the header
muse_table * muse_table_load(const char *aFilename, unsigned char aIFU)
Load a table file and its primary FITS header.