1 /* 2 # This file is part of the Astrometry.net suite. 3 # Licensed under a 3-clause BSD style license - see LICENSE 4 */ 5 6 #ifndef CATUTILS_H 7 #define CATUTILS_H 8 9 #include <sys/types.h> 10 #include <stdint.h> 11 12 #include "astrometry/fitsbin.h" 13 #include "astrometry/bl.h" 14 #include "astrometry/an-bool.h" 15 16 #define AN_FILETYPE_CATALOG "OBJS" 17 18 struct catalog { 19 int numstars; 20 21 int healpix; 22 int hpnside; 23 24 double* stars; 25 26 // optional table: star magnitudes and mag errors. 27 float* mag; 28 float* mag_err; 29 30 // optional tables: positional error ellipses, proper motions 31 float* sigma_radec; // sigma_ra, sigma_dec 32 float* proper_motion; // motion_ra, motion_dec 33 float* sigma_pm; // sigma_motion_ra, sigma_motion_dec 34 35 // optional table: star IDs 36 uint64_t* starids; 37 38 // while writing: storage for the extra fields. 39 fl* maglist; 40 fl* magerrlist; 41 fl* siglist; 42 fl* pmlist; 43 fl* sigpmlist; 44 bl* idlist; 45 46 fitsbin_t* fb; 47 }; 48 typedef struct catalog catalog; 49 50 catalog* catalog_open(char* catfn); 51 52 catalog* catalog_open_for_writing(char* catfn); 53 54 double* catalog_get_star(catalog* cat, int sid); 55 56 double* catalog_get_base(catalog* cat); 57 58 int catalog_write_star(catalog* cat, double* star); 59 60 int catalog_close(catalog* cat); 61 62 //void catalog_compute_radecminmax(catalog* cat); 63 64 int catalog_write_header(catalog* cat); 65 66 qfits_header* catalog_get_header(catalog* cat); 67 68 int catalog_fix_header(catalog* cat); 69 70 anbool catalog_has_mag(const catalog* cat); 71 72 void catalog_add_mag(catalog* cat, float mag); 73 void catalog_add_mag_err(catalog* cat, float magerr); 74 void catalog_add_sigmas(catalog* cat, float sra, float sdec); 75 void catalog_add_pms(catalog* cat, float sra, float sdec); 76 void catalog_add_sigma_pms(catalog* cat, float sra, float sdec); 77 void catalog_add_id(catalog* cat, uint64_t id); 78 79 /* 80 This should be called after writing all the star positions and 81 calling catalog_fix_header(). It appends the data in "cat->mags" 82 to the file as an extra FITS table. 83 */ 84 int catalog_write_mags(catalog* cat); 85 int catalog_write_mag_errs(catalog* cat); 86 int catalog_write_sigmas(catalog* cat); 87 int catalog_write_pms(catalog* cat); 88 int catalog_write_sigma_pms(catalog* cat); 89 int catalog_write_ids(catalog* cat); 90 91 #endif 92