Changeset 37807 for trunk/Ohana/src/libdvo
- Timestamp:
- Jan 11, 2015, 2:14:39 PM (12 years ago)
- Location:
- trunk/Ohana
- Files:
-
- 48 edited
- 7 copied
-
. (modified) (1 prop)
-
src/libdvo/Makefile (modified) (3 diffs)
-
src/libdvo/include/dvo.h (modified) (23 diffs)
-
src/libdvo/include/dvodb.h (modified) (7 diffs)
-
src/libdvo/include/libdvo_astro.h (modified) (2 diffs)
-
src/libdvo/include/ps1_sim_defs.h (copied) (copied from branches/eam_branches/ipp-20140904/Ohana/src/libdvo/include/ps1_sim_defs.h )
-
src/libdvo/include/ps1_v5_defs.h (modified) (1 diff)
-
src/libdvo/src/AstromOffsetMapIO.c (copied) (copied from branches/eam_branches/ipp-20140904/Ohana/src/libdvo/src/AstromOffsetMapIO.c )
-
src/libdvo/src/AstromOffsetMapOps.c (copied) (copied from branches/eam_branches/ipp-20140904/Ohana/src/libdvo/src/AstromOffsetMapOps.c )
-
src/libdvo/src/AstromOffsetMapUtils.c (copied) (copied from branches/eam_branches/ipp-20140904/Ohana/src/libdvo/src/AstromOffsetMapUtils.c )
-
src/libdvo/src/BoundaryTree.c (modified) (1 diff)
-
src/libdvo/src/HostTable.c (modified) (9 diffs)
-
src/libdvo/src/ImageMetadata.c (modified) (1 diff)
-
src/libdvo/src/ImageMetadataSelection.c (modified) (1 diff)
-
src/libdvo/src/ImageOps.c (modified) (2 diffs)
-
src/libdvo/src/ImageSelection.c (modified) (3 diffs)
-
src/libdvo/src/LoadImages.c (modified) (4 diffs)
-
src/libdvo/src/RegionHostTable.c (modified) (1 diff)
-
src/libdvo/src/astrom_maps.c (copied) (copied from branches/eam_branches/ipp-20140904/Ohana/src/libdvo/src/astrom_maps.c )
-
src/libdvo/src/coord_systems.c (modified) (5 diffs)
-
src/libdvo/src/coordops.c (modified) (9 diffs)
-
src/libdvo/src/dbExtractAverages.c (modified) (5 diffs)
-
src/libdvo/src/dbExtractImages.c (modified) (9 diffs)
-
src/libdvo/src/dbExtractMeasures.c (modified) (8 diffs)
-
src/libdvo/src/dbFields.c (modified) (8 diffs)
-
src/libdvo/src/dvo_catalog.c (modified) (17 diffs)
-
src/libdvo/src/dvo_catalog_create.c (modified) (3 diffs)
-
src/libdvo/src/dvo_catalog_mef.c (modified) (7 diffs)
-
src/libdvo/src/dvo_catalog_raw.c (modified) (8 diffs)
-
src/libdvo/src/dvo_catalog_split.c (modified) (32 diffs)
-
src/libdvo/src/dvo_convert.c (modified) (16 diffs)
-
src/libdvo/src/dvo_convert_PS1_DEV_1.c (modified) (2 diffs)
-
src/libdvo/src/dvo_convert_PS1_DEV_2.c (modified) (2 diffs)
-
src/libdvo/src/dvo_convert_PS1_DEV_3.c (modified) (2 diffs)
-
src/libdvo/src/dvo_convert_PS1_REF.c (modified) (2 diffs)
-
src/libdvo/src/dvo_convert_PS1_SIM.c (copied) (copied from branches/eam_branches/ipp-20140904/Ohana/src/libdvo/src/dvo_convert_PS1_SIM.c )
-
src/libdvo/src/dvo_convert_PS1_V1.c (modified) (2 diffs)
-
src/libdvo/src/dvo_convert_PS1_V2.c (modified) (2 diffs)
-
src/libdvo/src/dvo_convert_PS1_V3.c (modified) (2 diffs)
-
src/libdvo/src/dvo_convert_PS1_V4.c (modified) (2 diffs)
-
src/libdvo/src/dvo_convert_PS1_V5.c (modified) (9 diffs)
-
src/libdvo/src/dvo_convert_elixir.c (modified) (2 diffs)
-
src/libdvo/src/dvo_convert_loneos.c (modified) (2 diffs)
-
src/libdvo/src/dvo_convert_panstarrs_DEV_0.c (modified) (2 diffs)
-
src/libdvo/src/dvo_convert_panstarrs_DEV_1.c (modified) (2 diffs)
-
src/libdvo/src/dvo_image.c (modified) (4 diffs)
-
src/libdvo/src/dvo_image_raw.c (modified) (2 diffs)
-
src/libdvo/src/dvo_photcode_ops.c (modified) (1 diff)
-
src/libdvo/src/dvo_tiny_values.c (modified) (1 diff)
-
src/libdvo/src/dvo_util.c (modified) (1 diff)
-
src/libdvo/src/flatcorr_io.c (modified) (2 diffs)
-
src/libdvo/src/galaxy_model.c (copied) (copied from branches/eam_branches/ipp-20140904/Ohana/src/libdvo/src/galaxy_model.c )
-
src/libdvo/src/mosaic_astrom.c (modified) (4 diffs)
-
src/libdvo/src/skyregion_gsc.c (modified) (1 diff)
-
src/libdvo/src/skyregion_ops.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana
- Property svn:mergeinfo changed
-
trunk/Ohana/src/libdvo/Makefile
r37729 r37807 38 38 $(DESTINC)/ps1_v5_defs.h \ 39 39 $(DESTINC)/ps1_ref_defs.h \ 40 $(DESTINC)/ps1_sim_defs.h \ 40 41 $(DESTINC)/cmf-ps1-dv3.h \ 41 42 $(DESTINC)/cmf-ps1-v5.h \ … … 50 51 $(SRC)/version.$(ARCH).o \ 51 52 $(SRC)/coordops.$(ARCH).o \ 53 $(SRC)/galaxy_model.$(ARCH).o \ 52 54 $(SRC)/dvosorts.$(ARCH).o \ 53 55 $(SRC)/dvo_photcode_ops.$(ARCH).o \ … … 84 86 $(SRC)/dvo_convert_PS1_V5.$(ARCH).o \ 85 87 $(SRC)/dvo_convert_PS1_REF.$(ARCH).o \ 88 $(SRC)/dvo_convert_PS1_SIM.$(ARCH).o \ 86 89 $(SRC)/flatcorr_io.$(ARCH).o \ 87 90 $(SRC)/skyregion_io.$(ARCH).o \ 88 91 $(SRC)/skyregion_gsc.$(ARCH).o \ 89 92 $(SRC)/skyregion_ops.$(ARCH).o \ 93 $(SRC)/AstromOffsetMapIO.$(ARCH).o \ 94 $(SRC)/AstromOffsetMapOps.$(ARCH).o \ 95 $(SRC)/AstromOffsetMapUtils.$(ARCH).o \ 90 96 $(SRC)/dvo_set_skyregion.$(ARCH).o \ 91 97 $(SRC)/dvo_set_catdir.$(ARCH).o \ -
trunk/Ohana/src/libdvo/include/dvo.h
r37729 r37807 24 24 DVO_FORMAT_PS1_DEV_3, 25 25 DVO_FORMAT_PS1_REF, 26 DVO_FORMAT_PS1_SIM, 26 27 DVO_FORMAT_PS1_V1, 27 28 DVO_FORMAT_PS1_V2, … … 36 37 37 38 typedef enum {DVO_CAT_OPEN_FAIL, DVO_CAT_OPEN_OK, DVO_CAT_OPEN_EMPTY} DVOCatalogOpenModes; 38 39 typedef enum {40 PROJ_NONE, // undefined41 PROJ_ZEA, // zenithal42 PROJ_ZPL, // zenithal43 PROJ_ARC, // zenithal44 PROJ_STG, // zenithal45 PROJ_SIN, // zenithal46 PROJ_TAN, // zenithal47 PROJ_TNX, // zenithal48 PROJ_DIS, // zenithal (TAN + polyterms)49 PROJ_LIN, // cartesian50 PROJ_PLY, // cartesian51 PROJ_WRP, // cartesian52 PROJ_AIT, // pseudocyl53 PROJ_GLS, // pseudocyl54 PROJ_PAR, // pseudocyl55 } OhanaProjection;56 57 typedef enum {58 PROJ_MODE_NONE,59 PROJ_MODE_CARTESIAN,60 PROJ_MODE_ZENITHAL,61 PROJ_MODE_PSEUDOCYL,62 } OhanaProjectionMode;63 39 64 40 // these are used as NAN for types of int values … … 79 55 80 56 /* catalog values to be loaded */ 81 # define LOAD_NONE 0x000 82 # define LOAD_AVES 0x001 83 # define LOAD_MEAS 0x002 84 # define LOAD_MISS 0x004 85 # define LOAD_SECF 0x008 86 # define SKIP_AVES 0x010 87 # define SKIP_MEAS 0x020 88 # define SKIP_MISS 0x040 89 # define SKIP_SECF 0x080 90 # define LOAD_LENSING 0x100 91 # define LOAD_LENSOBJ 0x200 92 # define SKIP_LENSING 0x400 93 # define SKIP_LENSOBJ 0x800 57 # define LOAD_NONE 0x0000 58 # define LOAD_AVES 0x0001 59 # define LOAD_MEAS 0x0002 60 # define LOAD_MISS 0x0004 61 # define LOAD_SECF 0x0008 62 # define SKIP_AVES 0x0010 63 # define SKIP_MEAS 0x0020 64 # define SKIP_MISS 0x0040 65 # define SKIP_SECF 0x0080 66 # define LOAD_LENSING 0x0100 67 # define LOAD_LENSOBJ 0x0200 68 # define SKIP_LENSING 0x0400 69 # define SKIP_LENSOBJ 0x0800 70 # define LOAD_STARPAR 0x1000 71 # define SKIP_STARPAR 0x2000 94 72 95 73 /* photometry code types */ … … 114 92 ID_IMAGE_ASTROM_FEW = 0x00000100, /* currently too few measurements for astrometry */ 115 93 ID_IMAGE_PHOTOM_UBERCAL = 0x00000200, /* externally-supplied photometry zero point from ubercal analysis */ 94 ID_IMAGE_ASTROM_GMM = 0x00000400, /* image was fitted to positions corrected by the galaxy motion model */ 116 95 } DVOImageFlags; 117 96 … … 136 115 ID_MEAS_STACK_PRIMARY = 0x00010000, // this stack measurement is in the primary skycell 137 116 ID_MEAS_STACK_PHOT_SRC = 0x00020000, // this measurement supplied the stack photometry 117 ID_MEAS_ICRF_QSO = 0x00040000, // this measurement is an ICRF reference position 118 ID_MEAS_IMAGE_EPOCH = 0x00080000, // this measurement is registered to the image epoch (not tied to ref catalog epoch) 138 119 } DVOMeasureFlags; 139 120 … … 152 133 */ 153 134 135 /** these names were previously used for Average flags in old (LONEOS-era) dvo versions 136 ID_BAD_OBJECT = 0x00004000, // if all measurements are bad, set this bit 137 ID_MOVING = 0x00008000, // is a moving object 138 ID_ROCK = 0x0000a000, // 0x8000 + 0x2000 139 ID_GHOST = 0x0000c001, // 0x8000 + 0x4000 + 0x0001 140 ID_TRAIL = 0x0000c002, // 0x8000 + 0x4000 + 0x0002 141 ID_BLEED = 0x0000c003, // 0x8000 + 0x4000 + 0x0003 142 ID_COSMIC = 0x0000c004, // 0x8000 + 0x4000 + 0x0004 143 **/ 144 154 145 /* Average.flags values -- these values are 32 bit (as of PS1_V1) */ 155 146 typedef enum { 156 ID_STAR_FEW = 0x00000001, // used within relphot: skip star 157 ID_STAR_POOR = 0x00000002, // used within relphot: skip star 158 ID_PROPER = 0x00000400, // star with large proper motion 159 ID_TRANSIENT = 0x00001000, // is this mutually exclusive with USNO? 160 ID_VARIABLE = 0x00002000, // not currently set? 161 ID_ASTEROID = 0x00002000, // identified with an asteroid 162 ID_BAD_OBJECT = 0x00004000, // if all measurements are bad, set this bit 163 ID_MOVING = 0x00008000, // is a moving object 164 ID_ROCK = 0x0000a000, // 0x8000 + 0x2000 165 ID_GHOST = 0x0000c001, // 0x8000 + 0x4000 + 0x0001 166 ID_TRAIL = 0x0000c002, // 0x8000 + 0x4000 + 0x0002 167 ID_BLEED = 0x0000c003, // 0x8000 + 0x4000 + 0x0003 168 ID_COSMIC = 0x0000c004, // 0x8000 + 0x4000 + 0x0004 169 ID_STAR_FIT_AVE = 0x00010000, // average position fitted 170 ID_STAR_FIT_PM = 0x00020000, // proper motion fitted 171 ID_STAR_FIT_PAR = 0x00040000, // parallax fitted 172 ID_STAR_USE_AVE = 0x00080000, // average position used (not PM or PAR) 173 ID_STAR_USE_PM = 0x00100000, // proper motion used (not AVE or PAR) 174 ID_STAR_USE_PAR = 0x00200000, // parallax used (not AVE or PM) 175 ID_STAR_NO_ASTROM = 0x00400000, // mean astrometry could not be measured 176 ID_STAR_BAD_PM = 0x00800000, // mean astrometry could not be measured 177 ID_OBJ_EXT = 0x01000000, // extended in our data (eg, PS) 178 ID_OBJ_EXT_ALT = 0x02000000, // extended in external data (eg, 2MASS) 179 ID_OBJ_GOOD = 0x04000000, // good-quality measurement in our data (eg,PS) 180 ID_OBJ_GOOD_ALT = 0x08000000, // good-quality measurement in external data (eg, 2MASS) 181 ID_OBJ_GOOD_STACK = 0x10000000, // good-quality object in the stack (> 1 good stack) 147 ID_STAR_FEW = 0x00000001, // used within relphot: skip star 148 ID_STAR_POOR = 0x00000002, // used within relphot: skip star 149 ID_ICRF_QSO = 0x00000004, // object IDed with known ICRF quasar (may have ICRF position measurement) 150 ID_OTHEF_QSO = 0x00000008, // object IDed with known or suspected quasar, without ICRF reference data 151 ID_PROPER = 0x00000010, // star with large proper motion 152 ID_TRANSIENT = 0x00000020, // identified as a non-periodic (stationary) transient 153 ID_VARIABLE = 0x00000040, // identified as a period variable 154 ID_ASTEROID = 0x00000080, // identified with a known solar-system object (asteroid or other) 155 // bits 0x00000100 - 0x00008000 are currently unused 156 ID_STAR_FIT_AVE = 0x00010000, // average position fitted 157 ID_STAR_FIT_PM = 0x00020000, // proper motion fitted 158 ID_STAR_FIT_PAR = 0x00040000, // parallax fitted 159 ID_STAR_USE_AVE = 0x00080000, // average position used (not PM or PAR) 160 ID_STAR_USE_PM = 0x00100000, // proper motion used (not AVE or PAR) 161 ID_STAR_USE_PAR = 0x00200000, // parallax used (not AVE or PM) 162 ID_STAR_NO_ASTROM = 0x00400000, // mean astrometry could not be measured 163 ID_STAR_BAD_PM = 0x00800000, // mean astrometry could not be measured 164 ID_OBJ_EXT = 0x01000000, // extended in our data (eg, PS) 165 ID_OBJ_EXT_ALT = 0x02000000, // extended in external data (eg, 2MASS) 166 ID_OBJ_GOOD = 0x04000000, // good-quality measurement in our data (eg,PS) 167 ID_OBJ_GOOD_ALT = 0x08000000, // good-quality measurement in external data (eg, 2MASS) 168 ID_OBJ_GOOD_STACK = 0x10000000, // good-quality object in the stack (> 1 good stack) 182 169 ID_OBJ_SUSPECT_STACK = 0x20000000, // suspect object in the stack (> 1 good or suspect stack, < 2 good) 183 ID_OBJ_BAD_STACK = 0x40000000, // good-quality object in the stack (> 1 good stack)170 ID_OBJ_BAD_STACK = 0x40000000, // good-quality object in the stack (> 1 good stack) 184 171 } DVOAverageFlags; 185 172 … … 202 189 } DVOSecfiltFlags; 203 190 191 /* definitions for parallel dvo host information 192 XXX : need better names (safer namespace) 193 */ 194 195 typedef enum { 196 DATA_ON_TGT = 0x01, 197 DATA_ON_BCK = 0x02, 198 DATA_USE_BCK = 0x04, 199 200 DATA_COPY_FAILURE = 0x80, 201 } SkyTableDataFlags; 202 203 typedef enum { 204 HOST_STDIN = 0, 205 HOST_STDOUT = 1, 206 HOST_STDERR = 2, 207 } HostInfoIOfd; 208 204 209 /*** general dvo structures (internal use only / not IO) ***/ 205 210 … … 253 258 } FlatCorrectionTable; 254 259 255 /* definitions for parallel dvo host information256 XXX : need better names (safer namespace)257 */258 259 typedef enum {260 DATA_ON_TGT = 0x01,261 DATA_ON_BCK = 0x02,262 DATA_USE_BCK = 0x04,263 264 DATA_COPY_FAILURE = 0x80,265 } SkyTableDataFlags;266 267 typedef enum {268 HOST_STDIN = 0,269 HOST_STDOUT = 1,270 HOST_STDERR = 2,271 } HostInfoIOfd;272 273 260 typedef struct { 274 261 char *hostname; // name of remote machine … … 289 276 } HostTable; 290 277 278 typedef struct { 279 int Nhosts; 280 HostInfo **hosts; 281 } HostTableGroup; 282 291 283 // A RegionHost processes data for some region in parallel with other regions 292 284 typedef struct RegionHostInfo { … … 314 306 Image *image; 315 307 off_t *imseq; 308 309 AstromOffsetTable *astromTable; 316 310 317 311 int *neighbors; // list of neighbor index values … … 444 438 double R; 445 439 double D; 440 float RoffGAL; 441 float DoffGAL; 446 442 float M; 447 443 float Mcal; … … 645 641 int lensobjOffset; // offset to mean lensing data 646 642 int extendOffset; // offset to extended object entry 647 int paramsOffset;// offset to stellar parameter data643 int starparOffset; // offset to stellar parameter data 648 644 float refColorBlue; // color of astrometry ref stars 649 645 float refColorRed; // color of astrometry ref stars … … 679 675 Lensing *lensing; 680 676 Lensobj *lensobj; 677 StarPar *starpar; 681 678 682 679 int Nsecfilt; /* number of secfilt entries for each average entry */ 683 off_t Naverage, Nmeasure, Nmissing, Nlensing, Nlensobj, Ns ecf_mem; /* current number of each component in memory */684 off_t Naves_disk, Nmeas_disk, Nmiss_disk, Nlensing_disk, Nlensobj_disk, Ns ecf_disk; /* current number of each component on disk */685 off_t Naves_off, Nmeas_off, Nmiss_off, Nlensing_off, Nlensobj_off, Ns ecf_off; /* index of first loaded data value */680 off_t Naverage, Nmeasure, Nmissing, Nlensing, Nlensobj, Nstarpar, Nsecf_mem; /* current number of each component in memory */ 681 off_t Naves_disk, Nmeas_disk, Nmiss_disk, Nlensing_disk, Nlensobj_disk, Nstarpar_disk, Nsecf_disk; /* current number of each component on disk */ 682 off_t Naves_off, Nmeas_off, Nmiss_off, Nlensing_off, Nlensobj_off, Nstarpar_off, Nsecf_off; /* index of first loaded data value */ 686 683 687 684 // note that we use these for the full-sky relphot analysis … … 704 701 struct Catalog *lensing_catalog; /* lensing catalog data (split) */ 705 702 struct Catalog *lensobj_catalog; /* lensobj catalog data (split) */ 703 struct Catalog *starpar_catalog; /* starpar catalog data (split) */ 706 704 707 705 unsigned int objID; … … 739 737 int gfits_db_close PROTO((FITS_DB *db)); 740 738 int gfits_db_free PROTO((FITS_DB *db)); 741 742 /* in coords.c, using libautocode/def/coords.d */743 int XY_to_LM (double *L, double *M, double x, double y, Coords *coords);744 int LM_to_XY (double *x, double *y, double L, double M, Coords *coords);745 int RD_to_LM (double *L, double *M, double ra, double dec, Coords *coords);746 int LM_to_RD (double *ra, double *dec, double L, double M, Coords *coords);747 int XY_to_RD (double *ra, double *dec, double x, double y, Coords *coords);748 int RD_to_XY (double *x, double *y, double ra, double dec, Coords *coords);749 int fXY_to_RD (float *ra, float *dec, double x, double y, Coords *coords);750 int fRD_to_XY (float *x, float *y, double ra, double dec, Coords *coords);751 int GetCoords (Coords *coords, Header *header);752 int PutCoords (Coords *coords, Header *header);753 void RegisterMosaic (Coords *coords);754 void coords_precess (double *ra, double *dec, double in_epoch, double out_epoch);755 OhanaProjection GetProjection (char *ctype);756 int SetProjection (char *ctype, OhanaProjection proj);757 OhanaProjectionMode GetProjectionMode (OhanaProjection proj);758 739 759 740 char *libdvo_version (void); … … 913 894 Lensing *FtableToLensing (FTable *ftable, off_t *Nlensing, char *format); 914 895 Lensobj *FtableToLensobj (FTable *ftable, off_t *Nlensobj, char *format); 896 StarPar *FtableToStarPar (FTable *ftable, off_t *Nstarpar, char *format); 915 897 int FtableToImage (FTable *ftable, Header *theader, char *format); 916 898 … … 920 902 int LensingToFtable (FTable *ftable, Lensing *lensing, off_t Nlensing, char format); 921 903 int LensobjToFtable (FTable *ftable, Lensobj *lensobj, off_t Nlensobj, char format); 904 int StarParToFtable (FTable *ftable, StarPar *starpar, off_t Nstarpar, char format); 922 905 int ImageToFtable (FTable *ftable, Header *theader, char format); 923 906 int ImageToVtable (VTable *vtable, Header *theader, char format); … … 936 919 # include "ps1_v5_defs.h" 937 920 # include "ps1_ref_defs.h" 921 # include "ps1_sim_defs.h" 938 922 939 923 /*** DVO image db I/O Functions ***/ … … 950 934 void dvo_image_create (FITS_DB *db, double ZeroPoint); 951 935 936 int gfits_table_set_Image (FTable *ftable); 937 int gfits_table_mkheader_Image (Header *header); 938 Image *gfits_table_get_Image (FTable *ftable, off_t *Ndata, char *swapped); 939 952 940 /* flatcorr APIs */ 953 941 FlatCorrectionTable *FlatCorrectionLoad (char *filename, int VERBOSE); … … 963 951 SkyTable *SkyTableLoadOptimal PROTO((char *catdir, char *SKYFILE, char *GSCFILE, int readwrite, int depth, int VERBOSE)); 964 952 int SkyTableSetDepth PROTO((SkyTable *sky, int depth)); 953 SkyList *SkyRegionByIndex PROTO((SkyTable *table, int index)); 965 954 SkyList *SkyRegionByCPT PROTO((SkyTable *table, char *filename)); 966 955 SkyList *SkyRegionByPoint PROTO((SkyTable *table, int depth, double ra, double dec)); … … 1009 998 int HostTableTestHost (SkyRegion *region, int hostID); 1010 999 1000 void InitHost (HostInfo *host); 1001 1002 HostTableGroup *HostTableGroups (HostTable *table, int *ngroups); 1003 int HostTableGroupWaitJobsGetIO (HostTableGroup *table, char *file, int lineno, int VERBOSE); 1004 1011 1005 // functions to support tiny versions of Average and Measure 1012 1006 void CopyAverageToTiny (AverageTiny *averageT, Average *average); … … 1042 1036 void dvo_lensing_init (Lensing *lensing); 1043 1037 void dvo_lensobj_init (Lensobj *lensobj, int toZero); 1038 void dvo_starpar_init (StarPar *starpar); 1044 1039 1045 1040 void InitRegionHosts (RegionHostInfo *hosts, int Nhosts, int NHOSTS); … … 1051 1046 int RegionHostFindNeighbors (RegionHostTable *table, int Nhost); 1052 1047 1048 // galaxy_model: 1049 int TransformProperMotion_radians (double *uR, double *uD, double uL, double uB, double Rrad, double Drad, CoordTransform *transform); 1050 int TransformProperMotion (double *uR, double *uD, double uL, double uB, double R, double D, CoordTransform *transform); 1051 int SolarMotionModel_radians (double *uL_sol, double *uB_sol, double Lrad, double Brad, double distance); 1052 int SolarMotionModel (double *uL_sol, double *uB_sol, double L, double B, double distance); 1053 int GalaxyMotionModel_radians (double *uL_gal, double *uB_gal, double Lrad, double Brad); 1054 int GalaxyMotionModel (double *uL_gal, double *uB_gal, double L, double B); 1055 int InitGalaxyModel (char *version); 1056 1057 # define LENSFIELD(NAME) float LensValue_##NAME (PhotCode *code, Lensobj *lensobj); 1058 1059 LENSFIELD(X11_sm_obj) 1060 LENSFIELD(X12_sm_obj) 1061 LENSFIELD(X22_sm_obj) 1062 LENSFIELD(E1_sm_obj) 1063 LENSFIELD(E2_sm_obj) 1064 1065 LENSFIELD(X11_sh_obj) 1066 LENSFIELD(X12_sh_obj) 1067 LENSFIELD(X22_sh_obj) 1068 LENSFIELD(E1_sh_obj) 1069 LENSFIELD(E2_sh_obj) 1070 1071 LENSFIELD(X11_sm_psf) 1072 LENSFIELD(X12_sm_psf) 1073 LENSFIELD(X22_sm_psf) 1074 LENSFIELD(E1_sm_psf) 1075 LENSFIELD(E2_sm_psf) 1076 1077 LENSFIELD(X11_sh_psf) 1078 LENSFIELD(X12_sh_psf) 1079 LENSFIELD(X22_sh_psf) 1080 LENSFIELD(E1_sh_psf) 1081 LENSFIELD(E2_sh_psf) 1082 1083 # undef LENSFIELD 1084 1053 1085 # endif // DVO_H -
trunk/Ohana/src/libdvo/include/dvodb.h
r37116 r37807 55 55 MAG_OPTION_UC_DIST, 56 56 MAG_OPTION_FLAGS, 57 58 MAG_OPTION_X11_SM_OBJ, 59 MAG_OPTION_X12_SM_OBJ, 60 MAG_OPTION_X22_SM_OBJ, 61 MAG_OPTION_E1_SM_OBJ, 62 MAG_OPTION_E2_SM_OBJ, 63 64 MAG_OPTION_X11_SH_OBJ, 65 MAG_OPTION_X12_SH_OBJ, 66 MAG_OPTION_X22_SH_OBJ, 67 MAG_OPTION_E1_SH_OBJ, 68 MAG_OPTION_E2_SH_OBJ, 69 70 MAG_OPTION_X11_SM_PSF, 71 MAG_OPTION_X12_SM_PSF, 72 MAG_OPTION_X22_SM_PSF, 73 MAG_OPTION_E1_SM_PSF, 74 MAG_OPTION_E2_SM_PSF, 75 76 MAG_OPTION_X11_SH_PSF, 77 MAG_OPTION_X12_SH_PSF, 78 MAG_OPTION_X22_SH_PSF, 79 MAG_OPTION_E1_SH_PSF, 80 MAG_OPTION_E2_SH_PSF, 81 82 MAG_OPTION_F_AP_R5, 83 MAG_OPTION_F_ERR_AP_R5, 84 MAG_OPTION_F_STDEV_AP_R5, 85 MAG_OPTION_F_FILL_AP_R5, 86 87 MAG_OPTION_F_AP_R6, 88 MAG_OPTION_F_ERR_AP_R6, 89 MAG_OPTION_F_STDEV_AP_R6, 90 MAG_OPTION_F_FILL_AP_R6, 57 91 } dvoMagOptionType; 58 92 … … 139 173 MEAS_XFIX, 140 174 MEAS_YFIX, 175 MEAS_XOFF_KH, 176 MEAS_YOFF_KH, 177 MEAS_XOFF_DCR, 178 MEAS_YOFF_DCR, 179 MEAS_ROFF_GAL, 180 MEAS_DOFF_GAL, 141 181 MEAS_POS_SYS_ERR, 142 182 MEAS_XFIELD, … … 162 202 MEAS_FLAT, 163 203 MEAS_CENTER_OFFSET, 164 MEAS_REF_COLOR, 204 MEAS_REF_COLOR_BLUE, 205 MEAS_REF_COLOR_RED, 206 MEAS_X11_SM_OBJ, 207 MEAS_X12_SM_OBJ, 208 MEAS_X22_SM_OBJ, 209 MEAS_E1_SM_OBJ, 210 MEAS_E2_SM_OBJ, 211 MEAS_X11_SH_OBJ, 212 MEAS_X12_SH_OBJ, 213 MEAS_X22_SH_OBJ, 214 MEAS_E1_SH_OBJ, 215 MEAS_E2_SH_OBJ, 216 MEAS_X11_SM_PSF, 217 MEAS_X12_SM_PSF, 218 MEAS_X22_SM_PSF, 219 MEAS_E1_SM_PSF, 220 MEAS_E2_SM_PSF, 221 MEAS_X11_SH_PSF, 222 MEAS_X12_SH_PSF, 223 MEAS_X22_SH_PSF, 224 MEAS_E1_SH_PSF, 225 MEAS_E2_SH_PSF, 226 MEAS_E_BV, // extinction (mags) 227 MEAS_E_BV_ERR, 228 MEAS_DISTANCE_MOD, // distance modulus (mags) 229 MEAS_DISTANCE_MOD_ERR, 230 MEAS_M_R, // absolute mag in r-band 231 MEAS_M_R_ERR, 232 MEAS_FEH, // metallicity 233 MEAS_FEH_ERR, 234 MEAS_URA_GALMODEL, // model pm prediction 235 MEAS_UDEC_GALMODEL, // model pm prediction 236 MEAS_RA_GALMODEL, // model pm prediction 237 MEAS_DEC_GALMODEL, // model pm prediction 165 238 }; 166 239 … … 200 273 AVE_EXTID_HI, 201 274 AVE_EXTID_LO, 202 AVE_REF_COLOR, 275 AVE_REF_COLOR_BLUE, 276 AVE_REF_COLOR_RED, 203 277 AVE_PHOT, // photometry class of values 278 AVE_E_BV, // extinction (mags) 279 AVE_E_BV_ERR, 280 AVE_DISTANCE_MOD, // distance modulus (mags) 281 AVE_DISTANCE_MOD_ERR, 282 AVE_M_R, // absolute mag in r-band 283 AVE_M_R_ERR, 284 AVE_FEH, // metallicity 285 AVE_FEH_ERR, 286 AVE_URA_GALMODEL, // model pm prediction 287 AVE_UDEC_GALMODEL, // model pm prediction 288 AVE_RA_GALMODEL, // model pm prediction 289 AVE_DEC_GALMODEL, // model pm prediction 204 290 }; 205 291 … … 276 362 IMAGE_NLINK_PHOTOM, 277 363 IMAGE_NLINK_ASTROM, 278 IMAGE_REF_COLOR 364 IMAGE_REF_COLOR_BLUE, 365 IMAGE_REF_COLOR_RED 279 366 }; 280 367 … … 368 455 int ParseImageField PROTO((dbField *field, char *fieldName)); 369 456 370 dbValue dbExtractAverages PROTO((Average *average, SecFilt *secfilt, Measure *measure, dbField *field));371 dbValue dbExtractMeasures PROTO((Average *average, SecFilt *secfilt, Measure *measure, dbField *field));457 dbValue dbExtractAverages PROTO((Average *average, SecFilt *secfilt, Measure *measure, Lensobj *lensobj, StarPar *starpar, dbField *field)); 458 dbValue dbExtractMeasures PROTO((Average *average, SecFilt *secfilt, Measure *measure, Lensing *lensing, StarPar *starpar, dbField *field)); 372 459 dbValue dbExtractImages PROTO((Image *image, off_t Nimage, off_t N, dbField *field)); 373 460 … … 376 463 int dbAstroRegionLimits PROTO((dbStack **stack, int *nstack, SkyRegionSelection *selection, int table)); 377 464 char *strfloat PROTO((float value)); 465 466 int dbFieldNeedMeasure (dbField *fields, int Nfields); 467 int dbFieldNeedLensobj (dbField *fields, int Nfields); 468 int dbFieldNeedLensing (dbField *fields, int Nfields); 469 int dbFieldNeedStarpar (dbField *fields, int Nfields, int isAverage); 378 470 379 471 void FreeImageSelection (void); -
trunk/Ohana/src/libdvo/include/libdvo_astro.h
r31635 r37807 1 #ifdef notdef 2 # include "external.h" 3 # include "shell.h" 4 # include "dvomath.h" 5 # include "convert.h" 6 # include "display.h" 7 # include "data.h" 8 #endif 1 # ifndef LIBDVO_ASTRO_H 2 # define LIBDVO_ASTRO_H 9 3 10 # ifndef ASTRO_H 11 # define ASTRO_H 4 typedef enum { 5 COORD_NONE, 6 COORD_CELESTIAL, 7 COORD_GALACTIC, // based on Liu et al 2011 8 COORD_ECLIPTIC, 9 COORD_GALACTIC_REID_2004, // an older definition of the galactic plane 10 } CoordTransformSystem; 12 11 13 void InitAstro (void); 14 void FreeAstro (void); 12 typedef enum { 13 PROJ_NONE, // undefined 14 PROJ_ZEA, // zenithal 15 PROJ_ZPL, // zenithal 16 PROJ_ARC, // zenithal 17 PROJ_STG, // zenithal 18 PROJ_SIN, // zenithal 19 PROJ_TAN, // zenithal 20 PROJ_TNX, // zenithal 21 PROJ_DIS, // zenithal (TAN + polyterms) 22 PROJ_LIN, // cartesian 23 PROJ_PLY, // cartesian (allow polyterms) 24 PROJ_WRP, // cartesian (allow polyterms, require mosaic) 25 PROJ_AIT, // pseudocyl 26 PROJ_GLS, // pseudocyl 27 PROJ_PAR, // pseudocyl 28 } OhanaProjection; 29 30 typedef enum { 31 PROJ_MODE_NONE, 32 PROJ_MODE_CARTESIAN, 33 PROJ_MODE_ZENITHAL, 34 PROJ_MODE_PSEUDOCYL, 35 } OhanaProjectionMode; 15 36 16 37 typedef struct { … … 29 50 } CoordTransform; 30 51 31 typedef enum {COORD_NONE, COORD_CELESTIAL, COORD_GALACTIC, COORD_ECLIPTIC} CoordTransformSystem; 52 typedef struct { 53 int Nx; 54 int Ny; 55 float dX; 56 float dY; 57 float **dXv; 58 float **dYv; 59 unsigned int tableID; 60 unsigned int imageID; 61 int keep; 62 } AstromOffsetMap; 63 64 typedef struct { 65 int Nmap; 66 AstromOffsetMap **map; 67 int *imageIDtoTableSeq; 68 int MaxImageID; 69 int MaxTableID; 70 } AstromOffsetTable; 71 72 /* Internal version of Coords (see CoordsDisk in libautocode/def/coords-disk.d) */ 73 typedef struct Coords { 74 double crval1; // coordinate at reference pixel 75 double crval2; // coordinate at reference pixel 76 float crpix1; // coordinate of reference pixel 77 float crpix2; // coordinate of reference pixel 78 float cdelt1; // degrees per pixel 79 float cdelt2; // degrees per pixel 80 float pc1_1; // rotation matrix 81 float pc1_2; // rotation matrix 82 float pc2_1; // rotation matrix 83 float pc2_2; // rotation matrix 84 float polyterms[7][2]; // higher order warping terms 85 char ctype[15]; // coordinate type 86 char Npolyterms; // order of polynomial 87 struct Coords *mosaic; // pointer to parent mosaic 88 AstromOffsetMap *offsetMap; // pointer to offset map transformation 89 } Coords; 90 91 typedef struct Image { 92 Coords coords; // astrometric data 93 e_time tzero; // readout time (row 0) 94 unsigned int nstar; // number of stars on image 95 float secz; // airmass (mag) 96 unsigned short NX; // image width 97 unsigned short NY; // image height 98 float apmifit; // aperture correction (mag) 99 float dapmifit; // apmifit error (mag) 100 float Mcal; // calibration mag (mag) 101 float dMcal; // error on Mcal (mag) 102 short Xm; // image chisq (10*log(value)) 103 short photcode; // identifier for CCD, 104 float exptime; // exposure time (seconds) 105 float sidtime; // sidereal time of exposure 106 float latitude; // observatory latitude (degrees) 107 float RAo; // image center (degrees) 108 float DECo; // image center (degrees) 109 float Radius; // image radius (degrees) 110 float refColorBlue; // median astrometry ref color 111 float refColorRed; // median astrometry ref color 112 char name[117]; // name of original image 113 unsigned char detection_limit; // detection limit (10*mag) 114 unsigned char saturation_limit; // saturation limit (10*mag) 115 unsigned char cerror; // astrometric error (50*arcsec) 116 unsigned char fwhm_x; // PSF x width (25*arcsec) 117 unsigned char fwhm_y; // PSF y width (25*arcsec) 118 unsigned char trate; // scan rate (100 usec/pixel) 119 unsigned char ccdnum; // CCD ID number 120 unsigned int flags; // image quality flags 121 unsigned int imageID; // internal image ID 122 unsigned int parentID; // associated ref image 123 unsigned int externID; // external image ID 124 unsigned short sourceID; // analysis source ID 125 short nLinkAstrom; // mean number of matched measurements for astrometry 126 short nLinkPhotom; // mean number of matched measurements for astrometry 127 short ubercalDist; // distance to nearest ubercal image 128 float dXpixSys; // systematic astrometry error in X 129 float dYpixSys; // systematic astrometry error in Y 130 float dMagSys; // systematic photometry error 131 unsigned short nFitAstrom; // number of stars used for astrometry cal 132 unsigned short nFitPhotom; // number of stars used for photometry cal 133 unsigned int photom_map_id; // reference to 2D zero point map 134 unsigned int astrom_map_id; // reference to 2D astrometry map 135 struct Image *parent; // pointer to parent mosaic (not save to disk) 136 } Image; 32 137 33 138 CoordTransform *InitTransform (CoordTransformSystem input, CoordTransformSystem output); 34 139 int ApplyTransform (double *x, double *y, double X, double Y, CoordTransform *transform); 35 140 141 /* in coords.c */ 142 void InitCoords (Coords *coords, char *projection); 143 void CopyCoords (Coords *tgt, Coords *src); 144 145 int XY_to_LM (double *L, double *M, double x, double y, Coords *coords); 146 int LM_to_XY (double *x, double *y, double L, double M, Coords *coords); 147 int RD_to_LM (double *L, double *M, double ra, double dec, Coords *coords); 148 int LM_to_RD (double *ra, double *dec, double L, double M, Coords *coords); 149 int XY_to_RD (double *ra, double *dec, double x, double y, Coords *coords); 150 int RD_to_XY (double *x, double *y, double ra, double dec, Coords *coords); 151 int fXY_to_RD (float *ra, float *dec, double x, double y, Coords *coords); 152 int fRD_to_XY (float *x, float *y, double ra, double dec, Coords *coords); 153 int GetCoords (Coords *coords, Header *header); 154 int PutCoords (Coords *coords, Header *header); 155 void coords_precess (double *ra, double *dec, double in_epoch, double out_epoch); 156 OhanaProjection GetProjection (char *ctype); 157 int SetProjection (char *ctype, OhanaProjection proj); 158 OhanaProjectionMode GetProjectionMode (OhanaProjection proj); 159 160 /* in AstromOffsetMapIO.c */ 161 AstromOffsetTable *AstromOffsetMapLoad (char *filename, int VERBOSE); 162 int AstromOffsetMapSave (AstromOffsetTable *table, char *filename); 163 AstromOffsetTable *AstromOffsetMapToTable(AstromOffsetMap_Disk_6x6 *map_disk, off_t Nmap); 164 AstromOffsetMap_Disk_6x6 *AstromOffsetTableToMap(AstromOffsetTable *table, off_t *Nmap); 165 166 /* in AstromOffsetMapOps.c */ 167 float AstromOffsetMapValue (AstromOffsetMap *map, float x, float y, int xdir); 168 int AstromOffsetMapFit (AstromOffsetMap *map, float *x, float *y, float *f, int Npts, int xdir); 169 170 /* in AstromOffsetMapUtils.c */ 171 AstromOffsetMap *AstromOffsetMapInit (int Nx, int Ny); 172 void AstromOffsetMapFree (AstromOffsetMap *map); 173 174 int AstromOffsetTableNewMap (AstromOffsetTable *table, int Nx, int Ny, Image *image); 175 int AstromOffsetTableMatchChips (Image *images, off_t Nimages, AstromOffsetTable *table); 176 AstromOffsetTable *AstromOffsetTableInit(); 177 void AstromOffsetTableFree(AstromOffsetTable *table); 178 int AstromOffsetTableAddMapFromImage (AstromOffsetTable *table, Image *image); 179 void AstromOffsetMapPrint (AstromOffsetMap *map, char *filename); 180 int AstromOffsetMapRepair (AstromOffsetMap *map, int xdir); 181 AstromOffsetMap *AstromOffsetMapCopy (AstromOffsetMap *map); 182 void AstromOffsetMapCopyData (AstromOffsetMap *tgt, AstromOffsetMap *src); 183 void AstromOffsetMapSetOrder (AstromOffsetMap *map, int Nx, int Ny, Image *image); 184 36 185 # endif -
trunk/Ohana/src/libdvo/include/ps1_v5_defs.h
r37035 r37807 9 9 10 10 Lensing *Lensing_PS1_V5_ToInternal (Lensing_PS1_V5 *in, off_t Nvalues); 11 Lensing *Lensing_PS1_V5_ALT_ToInternal (Lensing_PS1_V5_ALT *in, off_t Nvalues); 11 12 Lensing_PS1_V5 *LensingInternalTo_PS1_V5 (Lensing *in, off_t Nvalues); 12 13 Lensobj *Lensobj_PS1_V5_ToInternal (Lensobj_PS1_V5 *in, off_t Nvalues); 13 14 Lensobj_PS1_V5 *LensobjInternalTo_PS1_V5 (Lensobj *in, off_t Nvalues); 14 15 16 StarPar *StarPar_PS1_V5_ToInternal (StarPar_PS1_V5 *in, off_t Nvalues); 17 StarPar_PS1_V5 *StarParInternalTo_PS1_V5 (StarPar *in, off_t Nvalues); 18 15 19 PhotCode *PhotCode_PS1_V5_To_Internal (PhotCode_PS1_V5 *in, off_t Nvalues); 16 20 PhotCode_PS1_V5 *PhotCode_Internal_To_PS1_V5 (PhotCode *in, off_t Nvalues); -
trunk/Ohana/src/libdvo/src/BoundaryTree.c
r37116 r37807 371 371 int BoundaryTreeCellCoords (BoundaryTree *tree, int *zone, int *band, double ra, double dec) { 372 372 373 ra = ohana_normalize_angle (ra); 374 373 375 // first, find the containing zone 374 376 -
trunk/Ohana/src/libdvo/src/HostTable.c
r35848 r37807 3 3 # include <sys/wait.h> 4 4 5 void InitHost (HostInfo *host) { 6 host->hostname = NULL; 7 host->pathname = NULL; 8 host->results = NULL; 9 host->stdio[HOST_STDIN] = -1; 10 host->stdio[HOST_STDOUT] = -1; 11 host->stdio[HOST_STDERR] = -1; 12 host->pid = 0; 13 return; 14 } 15 5 16 void InitHosts (HostInfo *hosts, int Nhosts, int NHOSTS) { 6 17 7 18 int i; 8 19 for (i = Nhosts; i < NHOSTS; i++) { 9 hosts[i].hostname = NULL; 10 hosts[i].pathname = NULL; 11 hosts[i].results = NULL; 12 hosts[i].stdio[HOST_STDIN] = -1; 13 hosts[i].stdio[HOST_STDOUT] = -1; 14 hosts[i].stdio[HOST_STDERR] = -1; 15 hosts[i].pid = 0; 20 InitHost (&hosts[i]); 16 21 } 17 22 return; … … 36 41 } 37 42 if (table->index) free (table->index); 43 free (table); 44 return; 45 } 46 47 // a HostTableGroup is a pointer set to one or more HostTable entries 48 void FreeTableGroup (HostTableGroup *table) { 49 50 if (!table) return; 51 if (table->hosts) { 52 free (table->hosts); 53 } 38 54 free (table); 39 55 return; … … 136 152 fclose (f); 137 153 return table; 154 } 155 156 // split a host table into Ngroups, each with a unique set of hosts 157 HostTableGroup *HostTableGroups (HostTable *table, int *ngroups) { 158 159 // identify the unique host names and the number of times they each exist 160 // (Host tables are not very large; I can afford to do this in an inefficient way) 161 int i, j, k; 162 163 int Nunique = 0; 164 char **unique_hosts = NULL; // an array of pointers to a set of the names 165 int *Nunique_hosts = NULL; // an array of pointers to the count of each 166 ALLOCATE ( unique_hosts, char *, table->Nhosts); 167 ALLOCATE (Nunique_hosts, int, table->Nhosts); 168 for (i = 0; i < table->Nhosts; i++) Nunique_hosts[i] = 0; 169 170 for (i = 0; i < table->Nhosts; i++) { 171 int found = FALSE; 172 for (j = 0; !found && (j < Nunique); j++) { 173 if (!strcmp(table->hosts[i].hostname, unique_hosts[j])) { 174 Nunique_hosts[j] ++; 175 found = TRUE; 176 } 177 } 178 if (!found) { 179 unique_hosts[Nunique] = table->hosts[i].hostname; 180 Nunique_hosts[Nunique] = 1; 181 Nunique ++; 182 } 183 } 184 185 int Ngroups = 0; 186 for (i = 0; i < Nunique; i++) { 187 Ngroups = MAX (Nunique_hosts[i], Ngroups); 188 } 189 190 HostTableGroup *groups = NULL; 191 int *foundHost = NULL; 192 193 ALLOCATE (foundHost, int, table->Nhosts); 194 ALLOCATE (groups, HostTableGroup, Ngroups); 195 196 for (i = 0; i < table->Nhosts; i++) foundHost[i] = FALSE; 197 198 // in each group, attempt to add one of each unique host 199 for (i = 0; i < Ngroups; i++) { 200 groups[i].Nhosts = 0; 201 ALLOCATE (groups[i].hosts, HostInfo *, Nunique); 202 for (j = 0; j < Nunique; j++) { 203 int found = FALSE; 204 for (k = 0; !found && (k < table->Nhosts); k++) { 205 if (foundHost[k]) continue; 206 if (strcmp(unique_hosts[j], table->hosts[k].hostname)) continue; 207 groups[i].hosts[groups[i].Nhosts] = &table->hosts[k]; 208 groups[i].Nhosts ++; 209 found = TRUE; 210 foundHost[k] = TRUE; 211 } 212 } 213 } 214 *ngroups = Ngroups; 215 return groups; 138 216 } 139 217 … … 255 333 256 334 // this loop has 2 chunks: (a) check for I/O + (b) check for jobs done 257 while ( 1) {335 while (Nfound < Nrunning) { 258 336 259 337 // Wait up to 0.5 second for host to provide I/O … … 284 362 // if (table->hosts[i].stdout.Nbuffer > 0x10000) { 285 363 if (table->hosts[i].stdout.Nbuffer > 0x1000) { 286 int printHead = VERBOSE ||(table->hosts[i].stdout.Nbuffer > 0);364 int printHead = VERBOSE && (table->hosts[i].stdout.Nbuffer > 0); 287 365 if (printHead) fprintf (stdout, "--- stdout from %s --- (%d bytes, v1)\n", table->hosts[i].hostname, table->hosts[i].stdout.Nbuffer); 288 366 int Nout = write (STDOUT_FILENO, table->hosts[i].stdout.buffer, table->hosts[i].stdout.Nbuffer); … … 298 376 // if (table->hosts[i].stderr.Nbuffer > 0x10000) { 299 377 if (table->hosts[i].stderr.Nbuffer > 0x1000) { 300 int printHead = VERBOSE ||(table->hosts[i].stderr.Nbuffer > 0);378 int printHead = VERBOSE && (table->hosts[i].stderr.Nbuffer > 0); 301 379 if (printHead) fprintf (stdout, "--- stderr from %s --- (%d bytes, v1)\n", table->hosts[i].hostname, table->hosts[i].stderr.Nbuffer); 302 380 int Nout = write (STDOUT_FILENO, table->hosts[i].stderr.buffer, table->hosts[i].stderr.Nbuffer); … … 314 392 if (!pid) { 315 393 // fprintf (stderr, "no hosts to harvest\n"); 316 usleep ( 500000);394 usleep (200000); 317 395 break; // no outstanding jobs have finished 318 396 } … … 367 445 } 368 446 } 369 if (!found) { 370 fprintf (stderr, "Programming error: failed to matched finished job to known host!\n"); 371 exit (2); 372 } 373 Nfound ++; 447 if (found) Nfound ++; 448 // we sometimes harvest children not in the list (eg, closed kapa window). just ignore 374 449 if (Nfound == Nrunning) goto escape; // we've harvested all jobs 375 450 } … … 389 464 } 390 465 466 // wait for all children to complete, report output to stdout 467 int HostTableGroupWaitJobsGetIO (HostTableGroup *table, char *file, int lineno, int VERBOSE) { 468 469 // we have launched table->Nhosts jobs; wait for all of them to complete... 470 // if one (N) failed to launch, we will get an ECHILD error from the last (N) calls 471 472 // we need to read any data waiting on stderr or stdout from these jobs, or the overfull 473 // buffers can cause a problem. we alternate between 'select' and 'waitpid' calls with 474 // timeouts for both 475 476 // add all hosts' sockets to the fd_sets 477 fd_set rdSet, wtSet; 478 FD_ZERO (&rdSet); 479 FD_ZERO (&wtSet); 480 481 // XXX can I set the fd_sets once, since I am not actually closing the fd's? 482 483 int globalStatus = TRUE; 484 485 int i; 486 int Nmax = 0; 487 for (i = 0; i < table->Nhosts; i++) { 488 if (!table->hosts[i][0].pid) continue; // any unconnected hosts should be skipped 489 FD_SET (table->hosts[i][0].stdio[HOST_STDIN], &wtSet); 490 Nmax = MAX (Nmax, table->hosts[i][0].stdio[HOST_STDIN]); 491 FD_SET (table->hosts[i][0].stdio[HOST_STDOUT], &rdSet); 492 Nmax = MAX (Nmax, table->hosts[i][0].stdio[HOST_STDOUT]); 493 FD_SET (table->hosts[i][0].stdio[HOST_STDERR], &rdSet); 494 Nmax = MAX (Nmax, table->hosts[i][0].stdio[HOST_STDERR]); 495 } 496 Nmax ++; 497 498 // need the list of connected hosts for exit test below 499 int Nrunning = 0; 500 for (i = 0; i < table->Nhosts; i++) { 501 if (!table->hosts[i][0].pid) continue; // any unconnected hosts should be skipped 502 Nrunning ++; 503 } 504 505 int Nfound = 0; 506 507 // this loop has 2 chunks: (a) check for I/O + (b) check for jobs done 508 while (1) { 509 510 // Wait up to 0.5 second for host to provide I/O 511 // timeout gets mucked: need to reset before each select 512 struct timeval timeout; 513 timeout.tv_sec = 10; 514 timeout.tv_usec = 500000; 515 516 int status = select (Nmax, NULL, &wtSet, NULL, &timeout); 517 if (status == -1) { 518 perror("select()"); 519 exit (2); 520 } 521 522 // we have some sockets to check, check sockets for all hosts 523 for (i = 0; (status > 0) && (i < table->Nhosts); i++) { 524 if (!table->hosts[i][0].pid) continue; // any unconnected hosts should be skipped 525 526 if (FALSE && FD_ISSET (table->hosts[i][0].stdio[HOST_STDIN], &wtSet)) { 527 // this host is waiting for input : this is an error, so exit 528 fprintf (stderr, "host %s is waiting for input\n", table->hosts[i][0].hostname); 529 abort(); 530 } 531 532 if ((table->hosts[i][0].stdio[HOST_STDOUT] > 0) && FD_ISSET (table->hosts[i][0].stdio[HOST_STDOUT], &rdSet)) { 533 // this host has waiting output : read to buffer, and dump if necessary 534 ReadtoIOBuffer (&table->hosts[i][0].stdout, table->hosts[i][0].stdio[HOST_STDOUT]); 535 // if (table->hosts[i][0].stdout.Nbuffer > 0x10000) { 536 if (table->hosts[i][0].stdout.Nbuffer > 0x1000) { 537 int printHead = VERBOSE || (table->hosts[i][0].stdout.Nbuffer > 0); 538 if (printHead) fprintf (stdout, "--- stdout from %s --- (%d bytes, v1)\n", table->hosts[i][0].hostname, table->hosts[i][0].stdout.Nbuffer); 539 int Nout = write (STDOUT_FILENO, table->hosts[i][0].stdout.buffer, table->hosts[i][0].stdout.Nbuffer); 540 if (Nout != table->hosts[i][0].stdout.Nbuffer) { fprintf (stderr, "(error writing log?)\n"); } 541 FlushIOBuffer (&table->hosts[i][0].stdout); 542 if (printHead) fprintf (stdout, "\n"); 543 } 544 } 545 546 if ((table->hosts[i][0].stdio[HOST_STDERR] > 0) && FD_ISSET (table->hosts[i][0].stdio[HOST_STDERR], &rdSet)) { 547 // this host has waiting output : read to buffer, and dump if necessary 548 ReadtoIOBuffer (&table->hosts[i][0].stderr, table->hosts[i][0].stdio[HOST_STDERR]); 549 // if (table->hosts[i][0].stderr.Nbuffer > 0x10000) { 550 if (table->hosts[i][0].stderr.Nbuffer > 0x1000) { 551 int printHead = VERBOSE || (table->hosts[i][0].stderr.Nbuffer > 0); 552 if (printHead) fprintf (stdout, "--- stderr from %s --- (%d bytes, v1)\n", table->hosts[i][0].hostname, table->hosts[i][0].stderr.Nbuffer); 553 int Nout = write (STDOUT_FILENO, table->hosts[i][0].stderr.buffer, table->hosts[i][0].stderr.Nbuffer); 554 if (Nout != table->hosts[i][0].stderr.Nbuffer) { fprintf (stderr, "(error writing log?)\n"); } 555 FlushIOBuffer (&table->hosts[i][0].stderr); 556 if (printHead) fprintf (stdout, "\n"); 557 } 558 } 559 } 560 561 // now check if any children have finished... 562 while (TRUE) { 563 int status = 0; 564 int pid = waitpid (-1, &status, WNOHANG); 565 if (!pid) { 566 // fprintf (stderr, "no hosts to harvest\n"); 567 usleep (500000); 568 break; // no outstanding jobs have finished 569 } 570 if ((pid == -1) && (errno == ECHILD)) goto escape; // no more jobs on which to wait 571 if ((pid == -1) && (errno != ECHILD)) { 572 fprintf (stderr, "programming error (2)? %s %d", file, lineno); 573 exit (2); 574 } 575 576 // find the host which has finished 577 int found = FALSE; 578 for (i = 0; (i < table->Nhosts) && !found; i++) { 579 if (table->hosts[i][0].pid != pid) continue; 580 found = TRUE; 581 582 HostInfo *host = table->hosts[i]; 583 584 // check on the status of this and report any output? 585 if (VERBOSE) fprintf (stdout, "job finished for %s (%d)\n", host->hostname, pid); 586 587 // read stdout 588 int printHead; 589 printHead = VERBOSE || (host->stdout.Nbuffer > 0); 590 EmptyIOBuffer (&host->stdout, 100, host->stdio[HOST_STDOUT]); 591 if (printHead) fprintf (stdout, "--- stdout from %s --- (%d bytes, v2)\n", host->hostname, host->stdout.Nbuffer); 592 int Nout = write (STDOUT_FILENO, host->stdout.buffer, host->stdout.Nbuffer); 593 if (Nout != host->stdout.Nbuffer) { fprintf (stderr, "(error writing log?)\n"); } 594 FlushIOBuffer (&host->stdout); 595 if (printHead) fprintf (stdout, "\n"); 596 597 // read stderr 598 printHead = VERBOSE || (host->stderr.Nbuffer > 0); 599 EmptyIOBuffer (&host->stderr, 100, host->stdio[HOST_STDERR]); 600 if (printHead) fprintf (stdout, "--- stderr from %s --- (%d bytes, v2)\n", host->hostname, host->stderr.Nbuffer); 601 Nout = write (STDOUT_FILENO, host->stderr.buffer, host->stderr.Nbuffer); 602 if (Nout != host->stderr.Nbuffer) { fprintf (stderr, "(error writing log?)\n"); } 603 FlushIOBuffer (&host->stderr); 604 if (printHead) fprintf (stdout, "\n"); 605 606 if (WIFEXITED(status)) { 607 if (VERBOSE) fprintf (stdout, "normal completion, exit status is %d\n", WEXITSTATUS(status)); 608 host->status = WEXITSTATUS(status); 609 if (host->status) { 610 fprintf (stdout, "job failed on %s\n", host->hostname); 611 globalStatus = FALSE; 612 } 613 } else { 614 host->status = -1; 615 fprintf (stdout, "job exited abnormally on %s\n", host->hostname); 616 globalStatus = FALSE; 617 continue; 618 } 619 } 620 if (!found) { 621 fprintf (stderr, "Programming error: failed to matched finished job to known host!\n"); 622 exit (2); 623 } 624 Nfound ++; 625 if (Nfound == Nrunning) goto escape; // we've harvested all jobs 626 } 627 } 628 629 escape: 630 631 // close all opened connections 632 for (i = 0; i < table->Nhosts; i++) { 633 if (!table->hosts[i][0].pid) continue; // any unconnected hosts should be skipped 634 close (table->hosts[i][0].stdio[HOST_STDIN]); 635 close (table->hosts[i][0].stdio[HOST_STDOUT]); 636 close (table->hosts[i][0].stdio[HOST_STDERR]); 637 } 638 639 return globalStatus; 640 } 641 391 642 int HostTableTestHost (SkyRegion *region, int hostID) { 392 643 -
trunk/Ohana/src/libdvo/src/ImageMetadata.c
r37035 r37807 156 156 // assign the storage arrays 157 157 for (i = 0; i < Nimage; i++) { 158 int Nmosaic = FindMosaicForImage (image, Nimage, i); 159 if (!Nmosaic) continue; 160 Nmosaic --; 158 if (!image[i].coords.mosaic) continue; 161 159 imageID[i] = image[i].imageID; 162 160 externID[i] = image[i].externID; 163 crval1[i] = image[Nmosaic].coords.crval1; 164 crval2[i] = image[Nmosaic].coords.crval2; 165 166 theta[i] = DEG_RAD*atan2(image[Nmosaic].coords.pc1_2, image[Nmosaic].coords.pc1_1); 161 Coords *mosaic = image[i].coords.mosaic; 162 163 crval1[i] = mosaic->crval1; 164 crval2[i] = mosaic->crval2; 165 166 theta[i] = DEG_RAD*atan2(mosaic->pc1_2, mosaic->pc1_1); 167 167 168 168 Mcal[i] = image[i].Mcal; -
trunk/Ohana/src/libdvo/src/ImageMetadataSelection.c
r36490 r37807 13 13 14 14 /* field defines a frame with 0,0 at the field center, and 1 arcsec / pixel */ 15 field.crpix1 = field.crpix2 = 0.0;15 InitCoords (&field, "DEC--SIN"); 16 16 field.cdelt1 = field.cdelt2 = 1.0 / 3600; 17 field.pc1_1 = field.pc2_2 = 1.0;18 field.pc1_2 = field.pc2_1 = 0.0;19 field.Npolyterms = 0;20 strcpy (field.ctype, "DEC--SIN");21 17 22 18 /* mosaic defines a frame with 0,0 at the mosaic center, and 1 arcsec / pixel */ 23 mosaic.crpix1 = mosaic.crpix2 = 0.0;19 InitCoords (&mosaic, "DEC--SIN"); 24 20 mosaic.cdelt1 = mosaic.cdelt2 = 1.0 / 3600; 25 mosaic.pc1_1 = mosaic.pc2_2 = 1.0;26 mosaic.pc1_2 = mosaic.pc2_1 = 0.0;27 mosaic.Npolyterms = 0;28 strcpy (mosaic.ctype, "DEC--SIN");29 21 30 22 if ((image = ImageMetadataLoad (filename, &Nimage)) == NULL) return (FALSE); -
trunk/Ohana/src/libdvo/src/ImageOps.c
r34088 r37807 55 55 if (TimeSelect && ((image[i].tzero < tzero) || (image[i].tzero+image[i].trate*image[i].NY > tzero + trange))) continue; 56 56 if (selection->useDisplay) { 57 if (!FindMosaicForImage (image, Nimage, i)) continue;58 57 // first check if region center is in image 59 58 status = RD_to_XY (&X, &Y, Rmid, graph.coords.crval2, &image[i].coords); … … 89 88 } 90 89 if (selection->useSkyregion) { 91 if (!FindMosaicForImage (image, Nimage, i)) continue;92 90 /* project this image to screen display coords */ 93 91 x[0] = 0; y[0] = 0; -
trunk/Ohana/src/libdvo/src/ImageSelection.c
r36490 r37807 22 22 23 23 if (mosaicMode) { 24 /* mosaic defines a frame with 0,0 at the mosaic center, and 1 arcsec / pixel */ 25 mosaic.crpix1 = mosaic.crpix2 = 0.0; 26 mosaic.cdelt1 = mosaic.cdelt2 = 1.0 / 3600; 27 mosaic.pc1_1 = mosaic.pc2_2 = 1.0; 28 mosaic.pc1_2 = mosaic.pc2_1 = 0.0; 29 mosaic.Npolyterms = 0; 30 strcpy (mosaic.ctype, "DEC--SIN"); 24 /* mosaic defines a frame with 0,0 at the mosaic center, and 1 arcsec / pixel */ 25 InitCoords (&mosaic, "DEC--SIN"); 26 mosaic.cdelt1 = mosaic.cdelt2 = 1.0 / 3600; 31 27 } 32 28 … … 64 60 } 65 61 if (m == -1) return (NULL); 66 if (!FindMosaicForImage (image, Nimage, m)) return (NULL);67 62 return (&image[m]); 68 63 } … … 85 80 } 86 81 if (m == -1) return (NULL); 87 if (!FindMosaicForImage (image, Nimage, m)) return (NULL);88 82 return (&image[m]); 89 83 } -
trunk/Ohana/src/libdvo/src/LoadImages.c
r33649 r37807 9 9 static Image *imageCache = NULL; 10 10 static off_t cacheNimage = 0; 11 AstromOffsetTable *table = NULL; 11 12 12 13 static time_t getLastModified(char *filename); … … 39 40 lastModified = 0; 40 41 } 41 42 42 43 43 gfits_db_init (&db); … … 77 77 } 78 78 79 // assign image->parent and image->coords.mosaic 80 BuildChipMatch (image, *Nimage); 81 // MARKTIME("build chip match: %f sec\n", dtime); 82 83 char mapfile[DVO_MAX_PATH]; 84 snprintf (mapfile, DVO_MAX_PATH, "%s/AstroMap.fits", catdir); 85 86 if (table) AstromOffsetTableFree(table); 87 table = AstromOffsetMapLoad (mapfile, FALSE); 88 89 // assign images.coords.offsetMap -> table->map[i] 90 if (table) { 91 AstromOffsetTableMatchChips (image, *Nimage, table); 92 } 93 79 94 return (image); 80 95 } … … 92 107 if (!dvoUseImageCache && (images != NULL)) { 93 108 free(images); 109 AstromOffsetTableFree (table); 94 110 } else { 95 111 // defer free until next LoadImages with a different or modified Images.dat -
trunk/Ohana/src/libdvo/src/RegionHostTable.c
r36630 r37807 31 31 hosts[i].Nneighbors = 0; 32 32 hosts[i].isNeighbor = FALSE; 33 34 hosts[i].astromTable = NULL; 33 35 } 34 36 return; -
trunk/Ohana/src/libdvo/src/coord_systems.c
r31635 r37807 1 1 # include "dvo.h" 2 # include "libdvo_astro.h"3 2 4 3 CoordTransform *InitTransform (CoordTransformSystem input, CoordTransformSystem output) { … … 40 39 // \delta^p_J = +27d 07' 41.7087" 41 40 // \theta_J = 122.93192526 deg 41 42 42 // these differ from the above at the several milliarcsec level 43 44 43 45 44 // These values were used in the past, but transform to/from B1950.0 … … 47 46 // transform->Xo = 282.25*RAD_DEG; 48 47 // transform->xo = 33.00; 48 49 break; 50 case COORD_GALACTIC_REID_2004: 51 52 // J2000 FK5 transformation from Reid et al 2004, ApJ 616, 872 53 transform->phi = (27.128336111 - 90.0)*RAD_DEG; // +27d 07' 42.01" (J2000) 54 transform->Xo = (192.859508333 + 90.0)*RAD_DEG; // 12h 51m 26.282s (J2000) 55 transform->xo = 32.932; 56 57 // comments from LSD code (lsd/builtins/misc.py, Mario Juric) 58 // # Appendix of Reid et al. (http://adsabs.harvard.edu/cgi-bin/bib_query?2004ApJ...616..872R) 59 // # This convention is also used by LAMBDA/WMAP (http://lambda.gsfc.nasa.gov/toolbox/tb_coordconv.cfm) 60 61 // _angp = np.radians(192.859508333) # 12h 51m 26.282s (J2000) 62 // _dngp = np.radians(27.128336111) # +27d 07' 42.01" (J2000) 63 // _l0 = np.radians(32.932) 49 64 50 65 break; … … 87 102 switch (output) { 88 103 case COORD_CELESTIAL: 89 // J2000 transformation from Liu et al 2011 ( )104 // J2000 transformation from Liu et al 2011 (A&A 526, A16) 90 105 transform->phi = 62.8717488056*RAD_DEG; 91 106 transform->Xo = 32.9319185700*RAD_DEG; 92 107 transform->xo = 282.8594812080; 108 109 // These values were used in the past, but transform to/from B1950.0 110 // transform->phi = 62.60*RAD_DEG; 111 // transform->Xo = 33.00*RAD_DEG; 112 // transform->xo = 282.25; 113 break; 114 case COORD_GALACTIC: 115 transform->phi = 0.0; 116 transform->Xo = 0.0; 117 transform->xo = 0.0; 118 transform->isIdentity = TRUE; 119 break; 120 case COORD_ECLIPTIC: 121 return NULL; 122 default: 123 abort(); 124 } 125 break; 126 case COORD_GALACTIC_REID_2004: 127 switch (output) { 128 case COORD_CELESTIAL: 129 // J2000 FK5 transformation from Reid et al 2004, ApJ 616, 872 130 transform->phi = (90.0 - 27.128336111)*RAD_DEG; // +27d 07' 42.01" (J2000) 131 transform->Xo = 32.932*RAD_DEG; 132 transform->xo = (192.859508333 + 90.0); // 12h 51m 26.282s (J2000) 93 133 94 134 // These values were used in the past, but transform to/from B1950.0 … … 144 184 Y *= RAD_DEG; 145 185 186 double cosY = cos(Y); 187 double sinY = sin(Y); 188 189 double cosX = cos(X); 190 double sinX = sin(X); 191 146 192 // recast with constants extracted: 147 sin_y = cos (Y)*sin(X)*transform->sin_phi_cos_Xo - cos(Y)*cos(X)*transform->sin_phi_sin_Xo + sin(Y)*transform->cos_phi;193 sin_y = cosY*sinX*transform->sin_phi_cos_Xo - cosY*cosX*transform->sin_phi_sin_Xo + sinY*transform->cos_phi; 148 194 cos_y = sqrt (1 - sin_y*sin_y); 149 195 150 sin_x = cos (Y)*sin(X)*transform->cos_phi_cos_Xo - cos(Y)*cos(X)*transform->cos_phi_sin_Xo - sin(Y)*transform->sin_phi;151 cos_x = cos (Y)*cos(X)*transform->cos_Xo + cos(Y)*sin(X)*transform->sin_Xo;196 sin_x = cosY*sinX*transform->cos_phi_cos_Xo - cosY*cosX*transform->cos_phi_sin_Xo - sinY*transform->sin_phi; 197 cos_x = cosY*cosX*transform->cos_Xo + cosY*sinX*transform->sin_Xo; 152 198 153 199 // atan2 returns -pi : +pi -
trunk/Ohana/src/libdvo/src/coordops.c
r37412 r37807 3 3 /* note that Coords.ctype carries the DEC (ctype2) value */ 4 4 5 static Coords mosaic; 6 static int gotMosaic = FALSE; 7 8 void RegisterMosaic (Coords *coords) { 9 mosaic = *coords; 10 gotMosaic = TRUE; 11 } 12 13 int isRegisteredMosaic () { 14 return (gotMosaic); 15 } 16 17 int GetMosaicCoords (Coords *coords) { 18 *coords = mosaic; 19 return (TRUE); 20 } 5 // default coordinates have unit scale and no rotation 6 void InitCoords (Coords *coords, char *projection) { 7 coords->crval1 = 0.0; 8 coords->crval2 = 0.0; 9 coords->crpix1 = 0.0; 10 coords->crpix2 = 0.0; 11 12 coords->cdelt1 = 1.0; 13 coords->cdelt2 = 1.0; 14 15 coords->pc1_1 = 1.0; // EW is flipped relative to sky parity (dRA/dX > 0) 16 coords->pc2_2 = 1.0; 17 coords->pc2_1 = 0.0; 18 coords->pc1_2 = 0.0; 19 20 coords->Npolyterms = 1; 21 coords->mosaic = NULL; 22 coords->offsetMap = NULL; 23 24 memset (coords->polyterms, 0, 7*2*sizeof(float)); 25 26 if (projection) { 27 strcpy (coords->ctype, projection); 28 } else { 29 strcpy (coords->ctype, "NONE"); 30 } 31 } 32 33 // default coordinates have unit scale and no rotation 34 void CopyCoords (Coords *tgt, Coords *src) { 35 tgt->crval1 = src->crval1; 36 tgt->crval2 = src->crval2; 37 tgt->crpix1 = src->crpix1; 38 tgt->crpix2 = src->crpix2; 39 tgt->cdelt1 = src->cdelt1; 40 tgt->cdelt2 = src->cdelt2; 41 tgt->pc1_1 = src->pc1_1; 42 tgt->pc2_2 = src->pc2_2; 43 tgt->pc2_1 = src->pc2_1; 44 tgt->pc1_2 = src->pc1_2; 45 tgt->Npolyterms = src->Npolyterms; 46 tgt->mosaic = src->mosaic; // pointer to another structure 47 tgt->offsetMap = src->offsetMap; // pointer to another structure 48 49 memcpy (tgt->polyterms, src->polyterms, 7*2*sizeof(float)); 50 strcpy (tgt->ctype, src->ctype); 51 } 21 52 22 53 int XY_to_LM (double *L, double *M, double x, double y, Coords *coords) { … … 28 59 proj = GetProjection (coords[0].ctype); 29 60 mode = GetProjectionMode (proj); 61 62 // if we have an image map, it should be applied to the pixel coordinates 63 // before anything else is done. It is easier to invert the map if it is 64 // of the form (dX,dY) = f(X,Y), then if (dL,dM) = f(X,Y). 65 if (coords[0].Npolyterms == -1) { 66 myAssert (coords[0].offsetMap, "offsetMap is requested by not defined"); 67 float dX = AstromOffsetMapValue (coords->offsetMap, x, y, TRUE); 68 float dY = AstromOffsetMapValue (coords->offsetMap, x, y, FALSE); 69 if (isnan(dX)) dX = 0.0; 70 if (isnan(dY)) dY = 0.0; 71 x += dX; 72 y += dY; 73 } 30 74 31 75 /** convert pixel coordinates to cartesian system **/ … … 78 122 /* mosaic astrometry : WRP is chip astrometry; apply mosaic (DIS) term */ 79 123 if (proj == PROJ_WRP) { 80 if (!gotMosaic) return (FALSE); 81 XY_to_RD (ra, dec, L, M, &mosaic); 124 if (!coords->mosaic) { 125 myAbort ("missing mosaic element"); 126 return (FALSE); 127 } 128 XY_to_RD (ra, dec, L, M, coords->mosaic); 82 129 } 83 130 return (TRUE); … … 149 196 *dec = DEG_RAD*delta; 150 197 151 *ra = ohana_normalize_angle (*ra);198 // *ra = ohana_normalize_angle (*ra); 152 199 153 200 return (TRUE); … … 182 229 *dec = delta + coords[0].crval2; 183 230 184 *ra = ohana_normalize_angle (*ra);231 // *ra = ohana_normalize_angle (*ra); 185 232 186 233 return (TRUE); … … 208 255 if (mode == PROJ_MODE_CARTESIAN) { 209 256 if (proj == PROJ_WRP) { 210 if (!gotMosaic) return (FALSE); 211 RD_to_XY (L, M, ra, dec, &mosaic); 257 if (!coords->mosaic) { 258 myAbort ("missing mosaic element"); 259 return (FALSE); 260 } 261 RD_to_XY (L, M, ra, dec, coords->mosaic); 212 262 return (TRUE); 213 263 } … … 381 431 *y = Yo / coords[0].cdelt2 + coords[0].crpix2; 382 432 433 // if we have an image map, it should be applied to the pixel coordinates 434 // after anything else is done. It is easier to invert the map if it is 435 // of the form (dX,dY) = f(X,Y), then if (dL,dM) = f(X,Y). 436 if (coords[0].Npolyterms == -1) { 437 myAssert (coords[0].offsetMap, "offsetMap is requested by not defined"); 438 439 double xraw = *x; 440 double yraw = *y; 441 442 double dXo = 0.0; 443 double dYo = 0.0; 444 445 int i; 446 for (i = 0; i < 4; i++) { 447 double dX = AstromOffsetMapValue (coords->offsetMap, xraw, yraw, TRUE); 448 double dY = AstromOffsetMapValue (coords->offsetMap, xraw, yraw, FALSE); 449 450 if (isnan(dX)) dX = 0.0; 451 if (isnan(dY)) dY = 0.0; 452 453 dX -= dXo; 454 dY -= dYo; 455 456 xraw -= dX; 457 yraw -= dY; 458 459 dXo += dX; 460 dYo += dY; 461 } 462 463 *x = xraw; 464 *y = yraw; 465 466 // I need to iterate since the position at which I have first made the correction is 467 // not the true position. but if dX,dY is small and the gradient of dX,dY is also 468 // small, then even a single pass gets us close. 469 470 // XXX test this and use a while (hypot(dX,dY) > XXX) condition 471 } 383 472 return (TRUE); 384 473 } … … 449 538 450 539 rotate = 0.0; 451 coords[0].crval1 = coords[0].crpix1 = coords[0].cdelt1 = 0.0; 452 coords[0].crval2 = coords[0].crpix2 = coords[0].cdelt2 = 0.0; 453 coords[0].pc1_1 = coords[0].pc2_2 = 1.0; 454 coords[0].pc2_1 = coords[0].pc1_2 = 0.0; 455 coords[0].Npolyterms = 1; 456 strcpy (coords[0].ctype, "NONE"); 540 541 InitCoords (coords, NULL); 457 542 458 543 mode = COORD_TYPE_NONE; … … 619 704 } 620 705 } 621 706 622 707 if (!status) { 623 708 // fprintf (stderr, "error getting all elements for coordinate mode %s\n", coords[0].ctype); -
trunk/Ohana/src/libdvo/src/dbExtractAverages.c
r37116 r37807 50 50 51 51 /* return average.field based on the selection */ 52 dbValue dbExtractAverages (Average *average, SecFilt *secfilt, Measure *measure, dbField *field) {52 dbValue dbExtractAverages (Average *average, SecFilt *secfilt, Measure *measure, Lensobj *lensobj, StarPar *starpar, dbField *field) { 53 53 54 54 // off_t i; … … 161 161 value.Flt = average[0].stargal; 162 162 break; 163 case AVE_REF_COLOR :163 case AVE_REF_COLOR_BLUE: 164 164 value.Flt = average[0].refColorBlue; 165 break; 166 case AVE_REF_COLOR_RED: 167 value.Flt = average[0].refColorRed; 165 168 break; 166 169 … … 306 309 value.Flt = PhotUCdist (field->photcode, average, secfilt); 307 310 break; 308 // XX case MAG_OPTION_STACK_DET_ID:309 // XX value.Int = PhotStackID (field->photcode, average, secfilt);310 // XX break;311 311 case MAG_OPTION_FLAGS: { 312 312 int Nsec = GetPhotcodeNsec (field->photcode->code); … … 315 315 break; 316 316 } 317 318 // g:X11_SM_OBJ, etc, are only valid for average 319 case MAG_OPTION_X11_SM_OBJ: { value.Flt = LensValue_X11_sm_obj (field->photcode, lensobj); break; } 320 case MAG_OPTION_X12_SM_OBJ: { value.Flt = LensValue_X12_sm_obj (field->photcode, lensobj); break; } 321 case MAG_OPTION_X22_SM_OBJ: { value.Flt = LensValue_X22_sm_obj (field->photcode, lensobj); break; } 322 case MAG_OPTION_E1_SM_OBJ: { value.Flt = LensValue_E1_sm_obj (field->photcode, lensobj); break; } 323 case MAG_OPTION_E2_SM_OBJ: { value.Flt = LensValue_E2_sm_obj (field->photcode, lensobj); break; } 324 325 case MAG_OPTION_X11_SH_OBJ: { value.Flt = LensValue_X11_sh_obj (field->photcode, lensobj); break; } 326 case MAG_OPTION_X12_SH_OBJ: { value.Flt = LensValue_X12_sh_obj (field->photcode, lensobj); break; } 327 case MAG_OPTION_X22_SH_OBJ: { value.Flt = LensValue_X22_sh_obj (field->photcode, lensobj); break; } 328 case MAG_OPTION_E1_SH_OBJ: { value.Flt = LensValue_E1_sh_obj (field->photcode, lensobj); break; } 329 case MAG_OPTION_E2_SH_OBJ: { value.Flt = LensValue_E2_sh_obj (field->photcode, lensobj); break; } 330 331 case MAG_OPTION_X11_SM_PSF: { value.Flt = LensValue_X11_sm_psf (field->photcode, lensobj); break; } 332 case MAG_OPTION_X12_SM_PSF: { value.Flt = LensValue_X12_sm_psf (field->photcode, lensobj); break; } 333 case MAG_OPTION_X22_SM_PSF: { value.Flt = LensValue_X22_sm_psf (field->photcode, lensobj); break; } 334 case MAG_OPTION_E1_SM_PSF: { value.Flt = LensValue_E1_sm_psf (field->photcode, lensobj); break; } 335 case MAG_OPTION_E2_SM_PSF: { value.Flt = LensValue_E2_sm_psf (field->photcode, lensobj); break; } 336 337 case MAG_OPTION_X11_SH_PSF: { value.Flt = LensValue_X11_sh_psf (field->photcode, lensobj); break; } 338 case MAG_OPTION_X12_SH_PSF: { value.Flt = LensValue_X12_sh_psf (field->photcode, lensobj); break; } 339 case MAG_OPTION_X22_SH_PSF: { value.Flt = LensValue_X22_sh_psf (field->photcode, lensobj); break; } 340 case MAG_OPTION_E1_SH_PSF: { value.Flt = LensValue_E1_sh_psf (field->photcode, lensobj); break; } 341 case MAG_OPTION_E2_SH_PSF: { value.Flt = LensValue_E2_sh_psf (field->photcode, lensobj); break; } 342 317 343 case MAG_OPTION_NONE: 318 344 break; 319 } 320 break; 345 346 default: 347 break; 348 } 349 break; 350 351 case AVE_E_BV: { value.Flt = starpar->Ebv; break; } 352 case AVE_E_BV_ERR: { value.Flt = starpar->dEbv; break; } 353 case AVE_DISTANCE_MOD: { value.Flt = starpar->DistMag; break; } 354 case AVE_DISTANCE_MOD_ERR: { value.Flt = starpar->dDistMag; break; } 355 case AVE_M_R: { value.Flt = starpar->M_r; break; } 356 case AVE_M_R_ERR: { value.Flt = starpar->dM_r; break; } 357 case AVE_FEH: { value.Flt = starpar->FeH; break; } 358 case AVE_FEH_ERR: { value.Flt = starpar->dFeH; break; } 359 case AVE_URA_GALMODEL: { value.Flt = starpar->uRA; break; } 360 case AVE_UDEC_GALMODEL: { value.Flt = starpar->uDEC; break; } 361 case AVE_RA_GALMODEL: { value.Flt = starpar->R; break; } 362 case AVE_DEC_GALMODEL: { value.Flt = starpar->D; break; } 321 363 322 364 case AVE_TYPE: … … 324 366 case AVE_TYPEFRAC: 325 367 break; 368 369 326 370 } 327 371 return (value); -
trunk/Ohana/src/libdvo/src/dbExtractImages.c
r37035 r37807 59 59 time_t t; 60 60 dbValue value; 61 off_t Nmosaic;62 61 63 62 value.Flt = NAN; … … 68 67 case IMAGE_RA: 69 68 if (!haveCelestial) { 70 if (!FindMosaicForImage (image, Nimage, N)) return value;71 69 if (!strcmp(&image[N].coords.ctype[4], "-DIS")) { 72 70 x = 0.0; … … 83 81 case IMAGE_DEC: 84 82 if (!haveCelestial) { 85 if (!FindMosaicForImage (image, Nimage, N)) return value;86 83 if (!strcmp(&image[N].coords.ctype[4], "-DIS")) { 87 84 x = 0.0; … … 99 96 if (!haveGalactic) { 100 97 if (!haveCelestial) { 101 if (!FindMosaicForImage (image, Nimage, N)) return value;102 98 if (!strcmp(&image[N].coords.ctype[4], "-DIS")) { 103 99 x = 0.0; … … 118 114 if (!haveGalactic) { 119 115 if (!haveCelestial) { 120 if (!FindMosaicForImage (image, Nimage, N)) return value;121 116 if (!strcmp(&image[N].coords.ctype[4], "-DIS")) { 122 117 x = 0.0; … … 137 132 if (!haveEcliptic) { 138 133 if (!haveCelestial) { 139 if (!FindMosaicForImage (image, Nimage, N)) return value;140 134 if (!strcmp(&image[N].coords.ctype[4], "-DIS")) { 141 135 x = 0.0; … … 156 150 if (!haveEcliptic) { 157 151 if (!haveCelestial) { 158 if (!FindMosaicForImage (image, Nimage, N)) return value;159 152 if (!strcmp(&image[N].coords.ctype[4], "-DIS")) { 160 153 x = 0.0; … … 269 262 270 263 case IMAGE_FWHM_MEDIAN: 271 if (!(Nmosaic = FindMosaicForImage (image, Nimage, N))) return value; 272 Nmosaic --; // XXX kind of a hack: FindMosaicForImage returns 0 or the mosaic seq number + 1 273 value.Flt = (image[Nmosaic].fwhm_x + image[Nmosaic].fwhm_y) / 50.0; 264 if (!image[N].parent) return value; 265 value.Flt = (image[N].parent->fwhm_x + image[N].parent->fwhm_y) / 50.0; 274 266 break; 275 267 case IMAGE_FWHM_MAJ_MEDIAN: 276 if (!(Nmosaic = FindMosaicForImage (image, Nimage, N))) return value; 277 Nmosaic --; // XXX kind of a hack: FindMosaicForImage returns 0 or the mosaic seq number + 1 278 value.Flt = image[Nmosaic].fwhm_x / 25.0; 268 if (!image[N].parent) return value; 269 value.Flt = image[N].parent->fwhm_x / 25.0; 279 270 break; 280 271 case IMAGE_FWHM_MIN_MEDIAN: 281 if (!(Nmosaic = FindMosaicForImage (image, Nimage, N))) return value; 282 Nmosaic --; // XXX kind of a hack: FindMosaicForImage returns 0 or the mosaic seq number + 1 283 value.Flt = image[Nmosaic].fwhm_y / 25.0; 272 if (!image[N].parent) return value; 273 value.Flt = image[N].parent->fwhm_y / 25.0; 284 274 break; 285 275 … … 375 365 break; 376 366 377 case IMAGE_REF_COLOR :367 case IMAGE_REF_COLOR_BLUE: 378 368 value.Flt = image[N].refColorBlue; 369 break; 370 case IMAGE_REF_COLOR_RED: 371 value.Flt = image[N].refColorRed; 379 372 break; 380 373 } -
trunk/Ohana/src/libdvo/src/dbExtractMeasures.c
r37246 r37807 85 85 86 86 /* return measure.field based on the selection */ 87 dbValue dbExtractMeasures (Average *average, SecFilt *secfilt, Measure *measure, dbField *field) {87 dbValue dbExtractMeasures (Average *average, SecFilt *secfilt, Measure *measure, Lensing *lensing, StarPar *starpar, dbField *field) { 88 88 89 89 int Nsec; … … 249 249 case MAG_OPTION_UC_DIST: 250 250 case MAG_OPTION_FLAGS: 251 case MAG_OPTION_X11_SM_OBJ: 252 case MAG_OPTION_X12_SM_OBJ: 253 case MAG_OPTION_X22_SM_OBJ: 254 case MAG_OPTION_E1_SM_OBJ: 255 case MAG_OPTION_E2_SM_OBJ: 256 case MAG_OPTION_X11_SH_OBJ: 257 case MAG_OPTION_X12_SH_OBJ: 258 case MAG_OPTION_X22_SH_OBJ: 259 case MAG_OPTION_E1_SH_OBJ: 260 case MAG_OPTION_E2_SH_OBJ: 261 case MAG_OPTION_X11_SM_PSF: 262 case MAG_OPTION_X12_SM_PSF: 263 case MAG_OPTION_X22_SM_PSF: 264 case MAG_OPTION_E1_SM_PSF: 265 case MAG_OPTION_E2_SM_PSF: 266 case MAG_OPTION_X11_SH_PSF: 267 case MAG_OPTION_X12_SH_PSF: 268 case MAG_OPTION_X22_SH_PSF: 269 case MAG_OPTION_E1_SH_PSF: 270 case MAG_OPTION_E2_SH_PSF: 271 case MAG_OPTION_F_AP_R5: 272 case MAG_OPTION_F_ERR_AP_R5: 273 case MAG_OPTION_F_STDEV_AP_R5: 274 case MAG_OPTION_F_FILL_AP_R5: 275 case MAG_OPTION_F_AP_R6: 276 case MAG_OPTION_F_ERR_AP_R6: 277 case MAG_OPTION_F_STDEV_AP_R6: 278 case MAG_OPTION_F_FILL_AP_R6: 279 251 280 case MAG_OPTION_NONE: 252 281 break; … … 474 503 break; 475 504 476 case MEAS_REF_COLOR :505 case MEAS_REF_COLOR_BLUE: 477 506 value.Flt = average[0].refColorBlue; 507 break; 508 case MEAS_REF_COLOR_RED: 509 value.Flt = average[0].refColorRed; 478 510 break; 479 511 … … 528 560 # endif 529 561 break; 530 case MEAS_XFIX: /* OK */ 531 value.Flt = measure[0].Xfix; 532 break; 533 case MEAS_YFIX: /* OK */ 534 value.Flt = measure[0].Yfix; 535 break; 536 case MEAS_XCCD_ERR: /* OK */ 537 value.Flt = FromShortPixels(measure[0].dXccd); 538 break; 539 case MEAS_YCCD_ERR: /* OK */ 540 value.Flt = FromShortPixels(measure[0].dYccd); 541 break; 542 case MEAS_POS_SYS_ERR: /* OK */ 543 value.Flt = FromShortPixels(measure[0].dRsys); 544 break; 562 case MEAS_XFIX: { value.Flt = measure[0].Xfix; break; } 563 case MEAS_YFIX: { value.Flt = measure[0].Yfix; break; } 564 case MEAS_XCCD_ERR: { value.Flt = FromShortPixels(measure[0].dXccd); break; } 565 case MEAS_YCCD_ERR: { value.Flt = FromShortPixels(measure[0].dYccd); break; } 566 case MEAS_POS_SYS_ERR: { value.Flt = FromShortPixels(measure[0].dRsys); } 567 568 case MEAS_XOFF_KH: { value.Flt = measure[0].XoffKH; break; } 569 case MEAS_YOFF_KH: { value.Flt = measure[0].YoffKH; break; } 570 case MEAS_XOFF_DCR: { value.Flt = measure[0].XoffDCR; break; } 571 case MEAS_YOFF_DCR: { value.Flt = measure[0].YoffDCR; break; } 572 case MEAS_ROFF_GAL: { value.Flt = measure[0].RoffGAL; break; } 573 case MEAS_DOFF_GAL: { value.Flt = measure[0].DoffGAL; break; } 545 574 546 575 case MEAS_XFIELD: /* offset relative to exposure center in ra,dec space */ … … 581 610 case MEAS_XMOSAIC: /* offset relative to exposure center in camera coords */ 582 611 if (!haveMosaicMeas) { 583 if (REMOTE_CLIENT) { 584 mosaic = MatchMosaicMetadata (measure[0].imageID); 585 } else { 586 // fprintf (stderr, "non-parallel Xmos broken\n"); 587 // abort(); 588 // mosaic = MatchMosaic (measure[0].t, measure[0].photcode); 589 mosaic = MatchMosaicMetadata (measure[0].imageID); 590 } 612 mosaic = MatchMosaicMetadata (measure[0].imageID); 591 613 if (mosaic == NULL) break; 592 614 double Rm = measure[0].R; … … 598 620 case MEAS_YMOSAIC: /* OK */ 599 621 if (!haveMosaicMeas) { 600 if (REMOTE_CLIENT) { 601 mosaic = MatchMosaicMetadata (measure[0].imageID); 602 } else { 603 // fprintf (stderr, "non-parallel Xmos broken\n"); 604 // abort(); 605 // mosaic = MatchMosaic (measure[0].t, measure[0].photcode); 606 mosaic = MatchMosaicMetadata (measure[0].imageID); 607 } 622 mosaic = MatchMosaicMetadata (measure[0].imageID); 608 623 if (mosaic == NULL) break; 609 624 double Rm = measure[0].R; … … 680 695 break; 681 696 682 case MEAS_MCAL_OFFSET: /* OK */ 683 value.Flt = measure[0].Mcal; 684 break; 697 case MEAS_MCAL_OFFSET: { value.Flt = measure[0].Mcal; break; } 685 698 686 699 case MEAS_FLAT: /* OK */ … … 717 730 } 718 731 break; 732 733 case MEAS_E_BV: { value.Flt = starpar->Ebv; break; } 734 case MEAS_E_BV_ERR: { value.Flt = starpar->dEbv; break; } 735 case MEAS_DISTANCE_MOD: { value.Flt = starpar->DistMag; break; } 736 case MEAS_DISTANCE_MOD_ERR: { value.Flt = starpar->dDistMag; break; } 737 case MEAS_M_R: { value.Flt = starpar->M_r; break; } 738 case MEAS_M_R_ERR: { value.Flt = starpar->dM_r; break; } 739 case MEAS_FEH: { value.Flt = starpar->FeH; break; } 740 case MEAS_FEH_ERR: { value.Flt = starpar->dFeH; break; } 741 case MEAS_URA_GALMODEL: { value.Flt = starpar->uRA; break; } 742 case MEAS_UDEC_GALMODEL: { value.Flt = starpar->uDEC; break; } 743 case MEAS_RA_GALMODEL: { value.Flt = starpar->R; break; } 744 case MEAS_DEC_GALMODEL: { value.Flt = starpar->D; break; } 719 745 720 746 // case MEAS_FLUX_PSF: /* OK */ -
trunk/Ohana/src/libdvo/src/dbFields.c
r37116 r37807 28 28 } 29 29 30 int dbFieldNeedMeasure (dbField *fields, int Nfields) { 31 int i; 32 for (i = 0; i < Nfields; i++) { 33 if (fields[i].photcode == NULL) continue; // non-measure fields do not have a photcode 34 if (fields[i].photcode[0].type == PHOT_REF) return TRUE; 35 if (fields[i].photcode[0].type == PHOT_DEP) return TRUE; 36 } 37 return FALSE; 38 } 39 40 int dbFieldNeedLensing (dbField *fields, int Nfields) { 41 int i; 42 for (i = 0; i < Nfields; i++) { 43 if (fields[i].ID == MEAS_X11_SM_OBJ) return TRUE; 44 if (fields[i].ID == MEAS_X12_SM_OBJ) return TRUE; 45 if (fields[i].ID == MEAS_X22_SM_OBJ) return TRUE; 46 if (fields[i].ID == MEAS_E1_SM_OBJ) return TRUE; 47 if (fields[i].ID == MEAS_E2_SM_OBJ) return TRUE; 48 if (fields[i].ID == MEAS_X11_SH_OBJ) return TRUE; 49 if (fields[i].ID == MEAS_X12_SH_OBJ) return TRUE; 50 if (fields[i].ID == MEAS_X22_SH_OBJ) return TRUE; 51 if (fields[i].ID == MEAS_E1_SH_OBJ) return TRUE; 52 if (fields[i].ID == MEAS_E2_SH_OBJ) return TRUE; 53 if (fields[i].ID == MEAS_X11_SM_PSF) return TRUE; 54 if (fields[i].ID == MEAS_X12_SM_PSF) return TRUE; 55 if (fields[i].ID == MEAS_X22_SM_PSF) return TRUE; 56 if (fields[i].ID == MEAS_E1_SM_PSF) return TRUE; 57 if (fields[i].ID == MEAS_E2_SM_PSF) return TRUE; 58 if (fields[i].ID == MEAS_X11_SH_PSF) return TRUE; 59 if (fields[i].ID == MEAS_X12_SH_PSF) return TRUE; 60 if (fields[i].ID == MEAS_X22_SH_PSF) return TRUE; 61 if (fields[i].ID == MEAS_E1_SH_PSF) return TRUE; 62 if (fields[i].ID == MEAS_E2_SH_PSF) return TRUE; 63 } 64 return FALSE; 65 } 66 67 int dbFieldNeedLensobj (dbField *fields, int Nfields) { 68 int i; 69 for (i = 0; i < Nfields; i++) { 70 if (fields[i].magOption == MAG_OPTION_NONE) continue; // non-measure fields do not have a photcode 71 72 if (fields[i].magOption == MAG_OPTION_X11_SM_OBJ) return TRUE; 73 if (fields[i].magOption == MAG_OPTION_X12_SM_OBJ) return TRUE; 74 if (fields[i].magOption == MAG_OPTION_X22_SM_OBJ) return TRUE; 75 if (fields[i].magOption == MAG_OPTION_E1_SM_OBJ) return TRUE; 76 if (fields[i].magOption == MAG_OPTION_E2_SM_OBJ) return TRUE; 77 if (fields[i].magOption == MAG_OPTION_X11_SH_OBJ) return TRUE; 78 if (fields[i].magOption == MAG_OPTION_X12_SH_OBJ) return TRUE; 79 if (fields[i].magOption == MAG_OPTION_X22_SH_OBJ) return TRUE; 80 if (fields[i].magOption == MAG_OPTION_E1_SH_OBJ) return TRUE; 81 if (fields[i].magOption == MAG_OPTION_E2_SH_OBJ) return TRUE; 82 if (fields[i].magOption == MAG_OPTION_X11_SM_PSF) return TRUE; 83 if (fields[i].magOption == MAG_OPTION_X12_SM_PSF) return TRUE; 84 if (fields[i].magOption == MAG_OPTION_X22_SM_PSF) return TRUE; 85 if (fields[i].magOption == MAG_OPTION_E1_SM_PSF) return TRUE; 86 if (fields[i].magOption == MAG_OPTION_E2_SM_PSF) return TRUE; 87 if (fields[i].magOption == MAG_OPTION_X11_SH_PSF) return TRUE; 88 if (fields[i].magOption == MAG_OPTION_X12_SH_PSF) return TRUE; 89 if (fields[i].magOption == MAG_OPTION_X22_SH_PSF) return TRUE; 90 if (fields[i].magOption == MAG_OPTION_E1_SH_PSF) return TRUE; 91 if (fields[i].magOption == MAG_OPTION_E2_SH_PSF) return TRUE; 92 } 93 return FALSE; 94 } 95 96 int dbFieldNeedStarpar (dbField *fields, int Nfields, int isAverage) { 97 int i; 98 for (i = 0; i < Nfields; i++) { 99 if (isAverage) { 100 if (fields[i].ID == AVE_E_BV) return TRUE; 101 if (fields[i].ID == AVE_E_BV_ERR) return TRUE; 102 if (fields[i].ID == AVE_DISTANCE_MOD) return TRUE; 103 if (fields[i].ID == AVE_DISTANCE_MOD_ERR) return TRUE; 104 if (fields[i].ID == AVE_M_R) return TRUE; 105 if (fields[i].ID == AVE_M_R_ERR) return TRUE; 106 if (fields[i].ID == AVE_FEH) return TRUE; 107 if (fields[i].ID == AVE_FEH_ERR) return TRUE; 108 if (fields[i].ID == AVE_URA_GALMODEL) return TRUE; 109 if (fields[i].ID == AVE_UDEC_GALMODEL) return TRUE; 110 if (fields[i].ID == AVE_RA_GALMODEL) return TRUE; 111 if (fields[i].ID == AVE_DEC_GALMODEL) return TRUE; 112 } else { 113 if (fields[i].ID == MEAS_E_BV) return TRUE; 114 if (fields[i].ID == MEAS_E_BV_ERR) return TRUE; 115 if (fields[i].ID == MEAS_DISTANCE_MOD) return TRUE; 116 if (fields[i].ID == MEAS_DISTANCE_MOD_ERR) return TRUE; 117 if (fields[i].ID == MEAS_M_R) return TRUE; 118 if (fields[i].ID == MEAS_M_R_ERR) return TRUE; 119 if (fields[i].ID == MEAS_FEH) return TRUE; 120 if (fields[i].ID == MEAS_FEH_ERR) return TRUE; 121 if (fields[i].ID == MEAS_URA_GALMODEL) return TRUE; 122 if (fields[i].ID == MEAS_UDEC_GALMODEL) return TRUE; 123 if (fields[i].ID == MEAS_RA_GALMODEL) return TRUE; 124 if (fields[i].ID == MEAS_DEC_GALMODEL) return TRUE; 125 } 126 } 127 return FALSE; 128 } 129 30 130 dvoMagSourceType GetMagSource (char *string) { 31 131 32 if (!strcasecmp (string, "chip")) return (MAG_SRC_CHP);33 if (!strcasecmp (string, "warp")) return (MAG_SRC_WRP);132 if (!strcasecmp (string, "chip")) return (MAG_SRC_CHP); 133 if (!strcasecmp (string, "warp")) return (MAG_SRC_WRP); 34 134 if (!strcasecmp (string, "stack")) return (MAG_SRC_STK); 35 135 … … 66 166 dvoMagOptionType GetMagOption (char *string) { 67 167 68 if (!strcasecmp (string, "mag")) return (MAG_OPTION_MAG); 69 if (!strcasecmp (string, "err")) return (MAG_OPTION_ERR); 70 if (!strcasecmp (string, "magerr")) return (MAG_OPTION_ERR); 71 if (!strcasecmp (string, "flux")) return (MAG_OPTION_FLUX); 72 if (!strcasecmp (string, "fluxerr")) return (MAG_OPTION_FLUX_ERR); 73 if (!strcasecmp (string, "stdev")) return (MAG_OPTION_STDEV); 74 if (!strcasecmp (string, "chisq")) return (MAG_OPTION_CHISQ); 75 if (!strcasecmp (string, "min")) return (MAG_OPTION_MIN); 76 if (!strcasecmp (string, "max")) return (MAG_OPTION_MAX); 77 if (!strcasecmp (string, "ncode")) return (MAG_OPTION_NCODE); 78 if (!strcasecmp (string, "nphot")) return (MAG_OPTION_NPHOT); 79 if (!strcasecmp (string, "uc_dist")) return (MAG_OPTION_UC_DIST); 80 if (!strcasecmp (string, "flags")) return (MAG_OPTION_FLAGS); 168 if (!strcasecmp (string, "mag")) return MAG_OPTION_MAG; 169 if (!strcasecmp (string, "err")) return MAG_OPTION_ERR; 170 if (!strcasecmp (string, "magerr")) return MAG_OPTION_ERR; 171 if (!strcasecmp (string, "flux")) return MAG_OPTION_FLUX; 172 if (!strcasecmp (string, "fluxerr")) return MAG_OPTION_FLUX_ERR; 173 if (!strcasecmp (string, "stdev")) return MAG_OPTION_STDEV; 174 if (!strcasecmp (string, "chisq")) return MAG_OPTION_CHISQ; 175 if (!strcasecmp (string, "min")) return MAG_OPTION_MIN; 176 if (!strcasecmp (string, "max")) return MAG_OPTION_MAX; 177 if (!strcasecmp (string, "ncode")) return MAG_OPTION_NCODE; 178 if (!strcasecmp (string, "nphot")) return MAG_OPTION_NPHOT; 179 if (!strcasecmp (string, "uc_dist")) return MAG_OPTION_UC_DIST; 180 if (!strcasecmp (string, "flags")) return MAG_OPTION_FLAGS; 181 if (!strcasecmp (string, "X11_SM_OBJ")) return MAG_OPTION_X11_SM_OBJ; 182 if (!strcasecmp (string, "X12_SM_OBJ")) return MAG_OPTION_X12_SM_OBJ; 183 if (!strcasecmp (string, "X22_SM_OBJ")) return MAG_OPTION_X22_SM_OBJ; 184 if (!strcasecmp (string, "E1_SM_OBJ")) return MAG_OPTION_E1_SM_OBJ; 185 if (!strcasecmp (string, "E2_SM_OBJ")) return MAG_OPTION_E2_SM_OBJ; 186 if (!strcasecmp (string, "X11_SH_OBJ")) return MAG_OPTION_X11_SH_OBJ; 187 if (!strcasecmp (string, "X12_SH_OBJ")) return MAG_OPTION_X12_SH_OBJ; 188 if (!strcasecmp (string, "X22_SH_OBJ")) return MAG_OPTION_X22_SH_OBJ; 189 if (!strcasecmp (string, "E1_SH_OBJ")) return MAG_OPTION_E1_SH_OBJ; 190 if (!strcasecmp (string, "E2_SH_OBJ")) return MAG_OPTION_E2_SH_OBJ; 191 if (!strcasecmp (string, "X11_SM_PSF")) return MAG_OPTION_X11_SM_PSF; 192 if (!strcasecmp (string, "X12_SM_PSF")) return MAG_OPTION_X12_SM_PSF; 193 if (!strcasecmp (string, "X22_SM_PSF")) return MAG_OPTION_X22_SM_PSF; 194 if (!strcasecmp (string, "E1_SM_PSF")) return MAG_OPTION_E1_SM_PSF; 195 if (!strcasecmp (string, "E2_SM_PSF")) return MAG_OPTION_E2_SM_PSF; 196 if (!strcasecmp (string, "X11_SH_PSF")) return MAG_OPTION_X11_SH_PSF; 197 if (!strcasecmp (string, "X12_SH_PSF")) return MAG_OPTION_X12_SH_PSF; 198 if (!strcasecmp (string, "X22_SH_PSF")) return MAG_OPTION_X22_SH_PSF; 199 if (!strcasecmp (string, "E1_SH_PSF")) return MAG_OPTION_E1_SH_PSF; 200 if (!strcasecmp (string, "E2_SH_PSF")) return MAG_OPTION_E2_SH_PSF; 201 // if (!strcasecmp (string, "F_AP_R5")) return MAG_OPTION_F_AP_R5; 202 // if (!strcasecmp (string, "F_ERR_AP_R5")) return MAG_OPTION_F_ERR_AP_R5; 203 // if (!strcasecmp (string, "F_STDEV_AP_R5")) return MAG_OPTION_F_STDEV_AP_R5; 204 // if (!strcasecmp (string, "F_FILL_AP_R5")) return MAG_OPTION_F_FILL_AP_R5; 205 // if (!strcasecmp (string, "F_AP_R6")) return MAG_OPTION_F_AP_R6; 206 // if (!strcasecmp (string, "F_ERR_AP_R6")) return MAG_OPTION_F_ERR_AP_R6; 207 // if (!strcasecmp (string, "F_STDEV_AP_R6")) return MAG_OPTION_F_STDEV_AP_R6; 208 // if (!strcasecmp (string, "F_FILL_AP_R6")) return MAG_OPTION_F_FILL_AP_R6; 81 209 82 210 return MAG_OPTION_NONE; 83 211 } 84 85 # if (0)86 int GetMagMode (char *string) {87 88 // these all imply PSF mags:89 if (!strcasecmp (string, "inst")) return (MAG_INST);90 if (!strcasecmp (string, "cat")) return (MAG_CAT);91 if (!strcasecmp (string, "sys")) return (MAG_SYS);92 if (!strcasecmp (string, "rel")) return (MAG_REL);93 if (!strcasecmp (string, "cal")) return (MAG_CAL);94 if (!strcasecmp (string, "ave")) return (MAG_AVE);95 if (!strcasecmp (string, "ref")) return (MAG_REF);96 if (!strcasecmp (string, "err")) return (MAG_ERR);97 if (!strcasecmp (string, "aveerr")) return (MAG_AVE_ERR);98 99 // these are explicit PSF mags:100 if (!strcasecmp (string, "psf_inst")) return (MAG_INST);101 if (!strcasecmp (string, "psf_cat")) return (MAG_CAT);102 if (!strcasecmp (string, "psf_sys")) return (MAG_SYS);103 if (!strcasecmp (string, "psf_rel")) return (MAG_REL);104 if (!strcasecmp (string, "psf_cal")) return (MAG_CAL);105 if (!strcasecmp (string, "psf_ave")) return (MAG_AVE);106 if (!strcasecmp (string, "psf_ref")) return (MAG_REF);107 if (!strcasecmp (string, "psf_err")) return (MAG_ERR);108 if (!strcasecmp (string, "psf_aveerr")) return (MAG_AVE_ERR);109 110 // these are aper mags:111 if (!strcasecmp (string, "ap")) return (MAG_APER);112 if (!strcasecmp (string, "aper")) return (MAG_APER);113 if (!strcasecmp (string, "aperinst")) return (MAG_APER_INST);114 if (!strcasecmp (string, "aper_inst")) return (MAG_APER_INST);115 if (!strcasecmp (string, "aper_cat")) return (MAG_APER_CAT);116 if (!strcasecmp (string, "aper_sys")) return (MAG_APER_SYS);117 if (!strcasecmp (string, "aper_rel")) return (MAG_APER_REL);118 if (!strcasecmp (string, "aper_cal")) return (MAG_APER_CAL);119 if (!strcasecmp (string, "aper_ave")) return (MAG_APER_AVE);120 if (!strcasecmp (string, "aper_ref")) return (MAG_APER_REF);121 if (!strcasecmp (string, "aper_err")) return (MAG_APER_ERR);122 123 // these are kron mags:124 if (!strcasecmp (string, "kron")) return (MAG_KRON);125 if (!strcasecmp (string, "kron_inst")) return (MAG_KRON_INST);126 if (!strcasecmp (string, "kron_cat")) return (MAG_KRON_CAT);127 if (!strcasecmp (string, "kron_sys")) return (MAG_KRON_SYS);128 if (!strcasecmp (string, "kron_rel")) return (MAG_KRON_REL);129 if (!strcasecmp (string, "kron_cal")) return (MAG_KRON_CAL);130 if (!strcasecmp (string, "kron_ave")) return (MAG_KRON_AVE);131 if (!strcasecmp (string, "kron_ref")) return (MAG_KRON_REF);132 if (!strcasecmp (string, "kron_err")) return (MAG_KRON_ERR);133 if (!strcasecmp (string, "kroninst")) return (MAG_KRON_INST);134 if (!strcasecmp (string, "kronerr")) return (MAG_KRON_ERR);135 136 // other fields:137 if (!strcasecmp (string, "photflags")) return (MAG_PHOT_FLAGS);138 if (!strcasecmp (string, "flags")) return (MAG_PHOT_FLAGS);139 if (!strcasecmp (string, "chisq")) return (MAG_CHISQ);140 if (!strcasecmp (string, "ncode")) return (MAG_NCODE);141 if (!strcasecmp (string, "nphot")) return (MAG_NPHOT);142 if (!strcasecmp (string, "stdev")) return (MAG_STDEV);143 if (!strcasecmp (string, "min")) return (MAG_MIN);144 if (!strcasecmp (string, "max")) return (MAG_MAX);145 if (!strcasecmp (string, "ucdist")) return (MAG_UC_DIST);146 if (!strcasecmp (string, "fluxpsf")) return (MAG_FLUX_PSF);147 if (!strcasecmp (string, "fluxpsferr")) return (MAG_FLUX_PSF_ERR);148 if (!strcasecmp (string, "fluxkron")) return (MAG_FLUX_KRON);149 if (!strcasecmp (string, "fluxkronerr")) return (MAG_FLUX_KRON_ERR);150 return (MAG_NONE);151 }152 # endif153 212 154 213 // field may be of the form mag:psf:inst:wrp. except for the first subword, … … 285 344 fprintf (stderr, "ERROR: unknown mag/photocode argument %s\n", word); 286 345 free (word); 346 return FALSE; 287 347 } 288 348 … … 414 474 if (!strcasecmp (fieldName, "XFIX")) ESCAPE (MEAS_XFIX, OPIHI_FLT); 415 475 if (!strcasecmp (fieldName, "YFIX")) ESCAPE (MEAS_YFIX, OPIHI_FLT); 476 if (!strcasecmp (fieldName, "XOFF_KH")) ESCAPE (MEAS_XOFF_KH, OPIHI_FLT); 477 if (!strcasecmp (fieldName, "YOFF_KH")) ESCAPE (MEAS_YOFF_KH, OPIHI_FLT); 478 if (!strcasecmp (fieldName, "XOFF_DCR")) ESCAPE (MEAS_XOFF_DCR, OPIHI_FLT); 479 if (!strcasecmp (fieldName, "YOFF_DCR")) ESCAPE (MEAS_YOFF_DCR, OPIHI_FLT); 480 if (!strcasecmp (fieldName, "ROFF_GAL")) ESCAPE (MEAS_ROFF_GAL, OPIHI_FLT); 481 if (!strcasecmp (fieldName, "DOFF_GAL")) ESCAPE (MEAS_DOFF_GAL, OPIHI_FLT); 416 482 if (!strcasecmp (fieldName, "POS_SYS_ERR")) ESCAPE (MEAS_POS_SYS_ERR, OPIHI_FLT); 417 483 if (!strcasecmp (fieldName, "XFIELD")) ESCAPE (MEAS_XFIELD, OPIHI_FLT); … … 441 507 if (!strcasecmp (fieldName, "FLAT")) ESCAPE (MEAS_FLAT, OPIHI_FLT); 442 508 if (!strcasecmp (fieldName, "CENTER_OFFSET")) ESCAPE (MEAS_CENTER_OFFSET, OPIHI_FLT); 443 // if (!strcasecmp (fieldName, "FLUX")) ESCAPE (MEAS_FLUX_PSF, OPIHI_FLT); 509 510 // individual lensing measurements are not grouped by photcode: 511 if (!strcasecmp (fieldName, "X11_SM_OBJ")) ESCAPE (MEAS_X11_SM_OBJ, OPIHI_FLT); 512 if (!strcasecmp (fieldName, "X12_SM_OBJ")) ESCAPE (MEAS_X12_SM_OBJ, OPIHI_FLT); 513 if (!strcasecmp (fieldName, "X22_SM_OBJ")) ESCAPE (MEAS_X22_SM_OBJ, OPIHI_FLT); 514 if (!strcasecmp (fieldName, "E1_SM_OBJ")) ESCAPE (MEAS_E1_SM_OBJ, OPIHI_FLT); 515 if (!strcasecmp (fieldName, "E2_SM_OBJ")) ESCAPE (MEAS_E2_SM_OBJ, OPIHI_FLT); 516 if (!strcasecmp (fieldName, "X11_SH_OBJ")) ESCAPE (MEAS_X11_SH_OBJ, OPIHI_FLT); 517 if (!strcasecmp (fieldName, "X12_SH_OBJ")) ESCAPE (MEAS_X12_SH_OBJ, OPIHI_FLT); 518 if (!strcasecmp (fieldName, "X22_SH_OBJ")) ESCAPE (MEAS_X22_SH_OBJ, OPIHI_FLT); 519 if (!strcasecmp (fieldName, "E1_SH_OBJ")) ESCAPE (MEAS_E1_SH_OBJ, OPIHI_FLT); 520 if (!strcasecmp (fieldName, "E2_SH_OBJ")) ESCAPE (MEAS_E2_SH_OBJ, OPIHI_FLT); 521 if (!strcasecmp (fieldName, "X11_SM_PSF")) ESCAPE (MEAS_X11_SM_PSF, OPIHI_FLT); 522 if (!strcasecmp (fieldName, "X12_SM_PSF")) ESCAPE (MEAS_X12_SM_PSF, OPIHI_FLT); 523 if (!strcasecmp (fieldName, "X22_SM_PSF")) ESCAPE (MEAS_X22_SM_PSF, OPIHI_FLT); 524 if (!strcasecmp (fieldName, "E1_SM_PSF")) ESCAPE (MEAS_E1_SM_PSF, OPIHI_FLT); 525 if (!strcasecmp (fieldName, "E2_SM_PSF")) ESCAPE (MEAS_E2_SM_PSF, OPIHI_FLT); 526 if (!strcasecmp (fieldName, "X11_SH_PSF")) ESCAPE (MEAS_X11_SH_PSF, OPIHI_FLT); 527 if (!strcasecmp (fieldName, "X12_SH_PSF")) ESCAPE (MEAS_X12_SH_PSF, OPIHI_FLT); 528 if (!strcasecmp (fieldName, "X22_SH_PSF")) ESCAPE (MEAS_X22_SH_PSF, OPIHI_FLT); 529 if (!strcasecmp (fieldName, "E1_SH_PSF")) ESCAPE (MEAS_E1_SH_PSF, OPIHI_FLT); 530 if (!strcasecmp (fieldName, "E2_SH_PSF")) ESCAPE (MEAS_E2_SH_PSF, OPIHI_FLT); 531 532 if (!strcasecmp (fieldName, "E_BV")) ESCAPE (MEAS_E_BV , OPIHI_FLT); 533 if (!strcasecmp (fieldName, "E_BV_ERR")) ESCAPE (MEAS_E_BV_ERR , OPIHI_FLT); 534 if (!strcasecmp (fieldName, "DISTANCE_MOD")) ESCAPE (MEAS_DISTANCE_MOD , OPIHI_FLT); 535 if (!strcasecmp (fieldName, "DISTANCE_MOD_ERR")) ESCAPE (MEAS_DISTANCE_MOD_ERR, OPIHI_FLT); 536 if (!strcasecmp (fieldName, "D_M")) ESCAPE (MEAS_DISTANCE_MOD , OPIHI_FLT); 537 if (!strcasecmp (fieldName, "D_M_ERR")) ESCAPE (MEAS_DISTANCE_MOD_ERR, OPIHI_FLT); 538 if (!strcasecmp (fieldName, "M_R")) ESCAPE (MEAS_M_R , OPIHI_FLT); 539 if (!strcasecmp (fieldName, "M_R_ERR")) ESCAPE (MEAS_M_R_ERR , OPIHI_FLT); 540 if (!strcasecmp (fieldName, "FEH")) ESCAPE (MEAS_FEH , OPIHI_FLT); 541 if (!strcasecmp (fieldName, "FEH_ERR")) ESCAPE (MEAS_FEH_ERR , OPIHI_FLT); 542 if (!strcasecmp (fieldName, "URA_GALMODEL")) ESCAPE (MEAS_URA_GALMODEL , OPIHI_FLT); 543 if (!strcasecmp (fieldName, "UDEC_GALMODEL")) ESCAPE (MEAS_UDEC_GALMODEL , OPIHI_FLT); 544 if (!strcasecmp (fieldName, "RA_GALMODEL")) ESCAPE (MEAS_RA_GALMODEL , OPIHI_FLT); 545 if (!strcasecmp (fieldName, "DEC_GALMODEL")) ESCAPE (MEAS_DEC_GALMODEL , OPIHI_FLT); 546 if (!strcasecmp (fieldName, "URA_GAL")) ESCAPE (MEAS_URA_GALMODEL , OPIHI_FLT); 547 if (!strcasecmp (fieldName, "UDEC_GAL")) ESCAPE (MEAS_UDEC_GALMODEL , OPIHI_FLT); 548 if (!strcasecmp (fieldName, "RA_GAL")) ESCAPE (MEAS_RA_GALMODEL , OPIHI_FLT); 549 if (!strcasecmp (fieldName, "DEC_GAL")) ESCAPE (MEAS_DEC_GALMODEL , OPIHI_FLT); 550 551 // if (!strcasecmp (fieldName, "FLUX")) ESCAPE (MEAS_FLUX_PSF, OPIHI_FLT); 444 552 // if (!strcasecmp (fieldName, "FLUX_ERR")) ESCAPE (MEAS_FLUX_PSF_ERR, OPIHI_FLT); 445 553 // if (!strcasecmp (fieldName, "FLUX_PSF")) ESCAPE (MEAS_FLUX_PSF, OPIHI_FLT); … … 447 555 // if (!strcasecmp (fieldName, "FLUX_KRON")) ESCAPE (MEAS_FLUX_KRON, OPIHI_FLT); 448 556 // if (!strcasecmp (fieldName, "FLUX_KRON_ERR")) ESCAPE (MEAS_FLUX_KRON_ERR, OPIHI_FLT); 449 if (!strcasecmp (fieldName, "REF_COLOR")) ESCAPE (MEAS_REF_COLOR, OPIHI_FLT); 557 if (!strcasecmp (fieldName, "REF_COLOR_BLUE")) ESCAPE (MEAS_REF_COLOR_BLUE, OPIHI_FLT); 558 if (!strcasecmp (fieldName, "REF_COLOR_RED")) ESCAPE (MEAS_REF_COLOR_RED, OPIHI_FLT); 450 559 451 560 // for words that don't parse, try a photcode … … 522 631 if (!strcasecmp (fieldName, "EXTID_HI")) ESCAPE (AVE_EXTID_HI, OPIHI_INT); 523 632 if (!strcasecmp (fieldName, "EXTID_LO")) ESCAPE (AVE_EXTID_LO, OPIHI_INT); 524 if (!strcasecmp (fieldName, "REF_COLOR")) ESCAPE (AVE_REF_COLOR, OPIHI_FLT); 633 if (!strcasecmp (fieldName, "REF_COLOR_BLUE")) ESCAPE (AVE_REF_COLOR_BLUE, OPIHI_FLT); 634 if (!strcasecmp (fieldName, "REF_COLOR_RED")) ESCAPE (AVE_REF_COLOR_RED, OPIHI_FLT); 635 636 if (!strcasecmp (fieldName, "E_BV")) ESCAPE (AVE_E_BV , OPIHI_FLT); 637 if (!strcasecmp (fieldName, "E_BV_ERR")) ESCAPE (AVE_E_BV_ERR , OPIHI_FLT); 638 if (!strcasecmp (fieldName, "DISTANCE_MOD")) ESCAPE (AVE_DISTANCE_MOD , OPIHI_FLT); 639 if (!strcasecmp (fieldName, "DISTANCE_MOD_ERR")) ESCAPE (AVE_DISTANCE_MOD_ERR, OPIHI_FLT); 640 if (!strcasecmp (fieldName, "M_R")) ESCAPE (AVE_M_R , OPIHI_FLT); 641 if (!strcasecmp (fieldName, "M_R_ERR")) ESCAPE (AVE_M_R_ERR , OPIHI_FLT); 642 if (!strcasecmp (fieldName, "FEH")) ESCAPE (AVE_FEH , OPIHI_FLT); 643 if (!strcasecmp (fieldName, "FEH_ERR")) ESCAPE (AVE_FEH_ERR , OPIHI_FLT); 644 if (!strcasecmp (fieldName, "URA_GALMODEL")) ESCAPE (AVE_URA_GALMODEL , OPIHI_FLT); 645 if (!strcasecmp (fieldName, "UDEC_GALMODEL")) ESCAPE (AVE_UDEC_GALMODEL , OPIHI_FLT); 646 if (!strcasecmp (fieldName, "RA_GALMODEL")) ESCAPE (AVE_RA_GALMODEL , OPIHI_FLT); 647 if (!strcasecmp (fieldName, "DEC_GALMODEL")) ESCAPE (AVE_DEC_GALMODEL , OPIHI_FLT); 648 525 649 526 650 // check for code:mode in photcode name … … 652 776 if (!strcasecmp (fieldName, "NLINK_PHOTOM")) ESCAPE (IMAGE_NLINK_PHOTOM, OPIHI_INT); 653 777 if (!strcasecmp (fieldName, "NLINK_ASTROM")) ESCAPE (IMAGE_NLINK_ASTROM, OPIHI_INT); 654 if (!strcasecmp (fieldName, "REF_COLOR")) ESCAPE (IMAGE_REF_COLOR, OPIHI_FLT); 778 if (!strcasecmp (fieldName, "REF_COLOR_BLUE")) ESCAPE (IMAGE_REF_COLOR_BLUE, OPIHI_FLT); 779 if (!strcasecmp (fieldName, "REF_COLOR_RED")) ESCAPE (IMAGE_REF_COLOR_RED, OPIHI_FLT); 655 780 656 781 // for words that don't parse, try a photcode -
trunk/Ohana/src/libdvo/src/dvo_catalog.c
r37356 r37807 58 58 if (!strcasecmp (catformat, "PS1_V5")) return (DVO_FORMAT_PS1_V5); 59 59 if (!strcasecmp (catformat, "PS1_REF")) return (DVO_FORMAT_PS1_REF); 60 if (!strcasecmp (catformat, "PS1_SIM")) return (DVO_FORMAT_PS1_SIM); 60 61 return (DVO_FORMAT_UNDEF); 61 62 } … … 129 130 average->Nlensing = 0; 130 131 average->Nlensobj = 0; 132 average->Nstarpar = 0; 131 133 average->Nextend = 0; 132 134 … … 135 137 average->lensingOffset = -1; 136 138 average->lensobjOffset = -1; 139 average->starparOffset = -1; 137 140 average->extendOffset = -1; 138 average->paramsOffset = -1;139 141 140 142 average->refColorBlue = NAN; … … 144 146 average->skycellID = 0; 145 147 average->projectionID = 0; 148 146 149 average->dummy = 0; 147 150 … … 437 440 438 441 // init all data, or just catalog data 442 void dvo_starpar_init (StarPar *starpar) { 443 starpar->R = NAN; 444 starpar->D = NAN; 445 starpar->galLat = NAN; 446 starpar->galLon = NAN; 447 starpar->Ebv = NAN; 448 starpar->dEbv = NAN; 449 starpar->DistMag = NAN; 450 starpar->dDistMag = NAN; 451 starpar->M_r = NAN; 452 starpar->dM_r = NAN; 453 starpar->FeH = NAN; 454 starpar->dFeH = NAN; 455 starpar->uRA = NAN; 456 starpar->uDEC = NAN; 457 starpar->averef = -1; 458 starpar->objID = -1; 459 starpar->catID = -1; 460 } 461 462 // init all data, or just catalog data 439 463 void dvo_catalog_init (Catalog *catalog, int complete) { 440 464 … … 462 486 catalog[0].lensobj = NULL; 463 487 488 catalog[0].starpar = NULL; 489 464 490 catalog[0].averageT = NULL; 465 491 catalog[0].measureT = NULL; … … 477 503 catalog[0].Nlensobj = 0; 478 504 505 catalog[0].Nstarpar = 0; 506 479 507 catalog[0].Naves_disk = 0; 480 508 catalog[0].Nmeas_disk = 0; … … 485 513 catalog[0].Nlensobj_disk = 0; 486 514 515 catalog[0].Nstarpar_disk = 0; 516 487 517 catalog[0].Naves_off = 0; 488 518 catalog[0].Nmeas_off = 0; … … 492 522 catalog[0].Nlensing_off = 0; 493 523 catalog[0].Nlensobj_off = 0; 524 525 catalog[0].Nstarpar_off = 0; 494 526 495 527 /* pointers to SPLIT data files */ … … 499 531 catalog[0].lensing_catalog = NULL; 500 532 catalog[0].lensobj_catalog = NULL; 533 catalog[0].starpar_catalog = NULL; 501 534 502 535 /* pointers for data manipulation */ … … 540 573 541 574 if (catalog[0].f == (FILE *) NULL) return (2); 542 fflush (catalog[0].f); 575 576 if (fflush (catalog[0].f)) { 577 fprintf (stderr, "failed to flush file\n"); 578 return FALSE; 579 } 580 543 581 // fprintf (stderr, "unlocking: %s\n", catalog[0].filename); 544 582 … … 552 590 553 591 // closes f but does not set back to NULL 554 fclearlockfile (catalog[0].filename, catalog[0].f, catalog[0].lockmode, &dbstate); 592 if (!fclearlockfile (catalog[0].filename, catalog[0].f, catalog[0].lockmode, &dbstate)) { 593 fprintf (stderr, "failed to unlock or close file\n"); 594 return (0); 595 } 555 596 556 597 if (catalog[0].catmode == DVO_MODE_SPLIT) { 557 if (catalog[0].measure_catalog) dvo_catalog_unlock (catalog[0].measure_catalog); 558 if (catalog[0].missing_catalog) dvo_catalog_unlock (catalog[0].missing_catalog); 559 if (catalog[0].secfilt_catalog) dvo_catalog_unlock (catalog[0].secfilt_catalog); 560 if (catalog[0].lensing_catalog) dvo_catalog_unlock (catalog[0].lensing_catalog); 561 if (catalog[0].lensobj_catalog) dvo_catalog_unlock (catalog[0].lensobj_catalog); 598 if (catalog[0].measure_catalog) { if (!dvo_catalog_unlock (catalog[0].measure_catalog)) { fprintf (stderr, "failed to unlock measures\n"); return (0); }} 599 if (catalog[0].missing_catalog) { if (!dvo_catalog_unlock (catalog[0].missing_catalog)) { fprintf (stderr, "failed to unlock missing\n"); return (0); }} 600 if (catalog[0].secfilt_catalog) { if (!dvo_catalog_unlock (catalog[0].secfilt_catalog)) { fprintf (stderr, "failed to unlock secfilt\n"); return (0); }} 601 if (catalog[0].lensing_catalog) { if (!dvo_catalog_unlock (catalog[0].lensing_catalog)) { fprintf (stderr, "failed to unlock lensing\n"); return (0); }} 602 if (catalog[0].lensobj_catalog) { if (!dvo_catalog_unlock (catalog[0].lensobj_catalog)) { fprintf (stderr, "failed to unlock lensobj\n"); return (0); }} 603 if (catalog[0].starpar_catalog) { if (!dvo_catalog_unlock (catalog[0].starpar_catalog)) { fprintf (stderr, "failed to unlock starpar\n"); return (0); }} 562 604 } 563 605 return (1); … … 597 639 } 598 640 641 // NOTE: this only check if we can write a backup; it does not actually write the backup 599 642 if (!check_file_access (catalog[0].filename, BACKUP, READWRITE, VERBOSE)) { 600 643 fprintf (stderr, "no permission to access %s\n", catalog[0].filename); … … 835 878 free (catalog[0].lensobj_catalog); 836 879 } 880 if (catalog[0].starpar_catalog) { 881 free (catalog[0].starpar_catalog[0].filename); 882 dvo_catalog_free (catalog[0].starpar_catalog); 883 free (catalog[0].starpar_catalog); 884 } 837 885 } 838 886 dvo_catalog_free_data (catalog); … … 873 921 catalog[0].Nlensobj = 0; 874 922 catalog[0].lensobj = NULL; 923 } 924 if (catalog[0].starpar) { 925 free (catalog[0].starpar); 926 catalog[0].Nstarpar = 0; 927 catalog[0].starpar = NULL; 875 928 } 876 929 if (catalog[0].nOwn_t) { free (catalog[0].nOwn_t); catalog[0].nOwn_t = NULL; } … … 985 1038 } 986 1039 } 1040 if (catalog[0].starpar_catalog != NULL) { 1041 if (catalog[0].Nstarpar_disk == 0) { 1042 // need to relock (and re-open) file for close elsewhere 1043 status = dvo_catalog_lock (catalog[0].starpar_catalog, lockmode); 1044 } else { 1045 if (!dvo_catalog_backup (catalog[0].starpar_catalog, FALSE)) { 1046 return FALSE; 1047 } 1048 } 1049 } 987 1050 } 988 1051 return TRUE; … … 1036 1099 } 1037 1100 } 1101 if ((catalog[0].starpar_catalog != NULL) && (catalog[0].Nstarpar_disk > 0)) { 1102 if (!dvo_catalog_unlink_backup (catalog[0].starpar_catalog, FALSE)) { 1103 return FALSE; 1104 } 1105 } 1038 1106 } 1039 1107 return TRUE; -
trunk/Ohana/src/libdvo/src/dvo_catalog_create.c
r37035 r37807 95 95 free (file); 96 96 97 /* define starpar catalog file */ 98 ALLOCATE (catalog[0].starpar_catalog, Catalog, 1); 99 dvo_catalog_init (catalog[0].starpar_catalog, TRUE); 100 101 /* create basic data for starpar catalog file */ 102 gfits_create_header (&catalog[0].starpar_catalog[0].header); 103 ALLOCATE (catalog[0].starpar_catalog[0].filename, char, length); 104 sprintf (catalog[0].starpar_catalog[0].filename, "%s/%s.cpz", path, root); 105 file = filebasename (catalog[0].starpar_catalog[0].filename); 106 gfits_modify (&catalog[0].header, "STARPAR", "%s", 1, file); 107 free (file); 108 97 109 free (path); 98 110 free (root); … … 117 129 } 118 130 if (dvo_catalog_lock (catalog[0].lensobj_catalog, catalog[0].lockmode) != DVO_CAT_OPEN_EMPTY) { 131 fprintf (stderr, "error with file lock\n"); 132 exit (2); 133 } 134 if (dvo_catalog_lock (catalog[0].starpar_catalog, catalog[0].lockmode) != DVO_CAT_OPEN_EMPTY) { 119 135 fprintf (stderr, "error with file lock\n"); 120 136 exit (2); … … 146 162 ALLOCATE (catalog[0].lensing, Lensing, 1); 147 163 ALLOCATE (catalog[0].lensobj, Lensobj, 1); 164 ALLOCATE (catalog[0].starpar, StarPar, 1); 148 165 149 166 /* setup secondary filters to match photcodes: -
trunk/Ohana/src/libdvo/src/dvo_catalog_mef.c
r37035 r37807 4 4 5 5 off_t Nbytes; 6 off_t Naverage;7 off_t Nmeasure;8 off_t Nmissing;9 off_t Nlensing;10 off_t Nlensobj;11 6 off_t Nitems, Nexpect; 12 7 int Nsecfilt; … … 18 13 19 14 ftable.header = &header; 20 21 /* get the components from the header */22 if (!gfits_scan (&catalog[0].header, "NSTARS", OFF_T_FMT, 1, &Naverage)) return (FALSE);23 if (!gfits_scan (&catalog[0].header, "NMEAS", OFF_T_FMT, 1, &Nmeasure)) return (FALSE);24 if (!gfits_scan (&catalog[0].header, "NMISS", OFF_T_FMT, 1, &Nmissing)) return (FALSE);25 if (!gfits_scan (&catalog[0].header, "NSECFILT", "%d", 1, &Nsecfilt)) Nsecfilt = 0;26 if (!gfits_scan (&catalog[0].header, "NLENSING", OFF_T_FMT, 1, &Nlensing)) return (FALSE);27 if (!gfits_scan (&catalog[0].header, "NLENSOBJ", OFF_T_FMT, 1, &Nlensobj)) return (FALSE);28 15 29 16 /* the OBJID is a counter that uniquely defines an average entry and never changes. if … … 38 25 catalog[0].catID = 0; 39 26 } 27 28 // NSTARS, average, Naves_disk 29 30 # define GET_TABLE_SIZES(HFIELD, CFIELD, DFIELD, REQUIRED) \ 31 off_t N##CFIELD; \ 32 if (REQUIRED) { \ 33 if (!gfits_scan (&catalog[0].header, HFIELD, OFF_T_FMT, 1, &N##CFIELD)) return (FALSE); \ 34 } else { \ 35 if (!gfits_scan (&catalog[0].header, HFIELD, OFF_T_FMT, 1, &N##CFIELD)) N##CFIELD = 0; \ 36 } \ 37 /* save the current number so we can do partial updates */ \ 38 catalog[0].DFIELD = N##CFIELD; \ 39 /* default values, but we will assign these a valid value before we exit (even if empty) */ \ 40 catalog[0].CFIELD = NULL; 40 41 41 /* save the current number so we can do partial updates*/42 catalog[0].Naves_disk = Naverage;43 catalog[0].Nmeas_disk = Nmeasure;44 catalog[0].Nmiss_disk = Nmissing;45 catalog[0].Nsecf_disk = Naverage * Nsecfilt;46 catalog[0].Nlensing_disk = Nlensing;47 catalog[0].Nlensobj_disk = Nlensobj;42 /* get the components and sizes from the header */ 43 GET_TABLE_SIZES ("NSTARS", average, Naves_disk, TRUE); 44 GET_TABLE_SIZES ("NMEAS", measure, Nmeas_disk, TRUE); 45 GET_TABLE_SIZES ("NMISS", missing, Nmiss_disk, FALSE); 46 GET_TABLE_SIZES ("NLENSING", lensing, Nlensing_disk, FALSE); 47 GET_TABLE_SIZES ("NLENSOBJ", lensobj, Nlensobj_disk, FALSE); 48 GET_TABLE_SIZES ("NSTARPAR", starpar, Nstarpar_disk, FALSE); 48 49 49 50 /** Nsecfilt is unusual: it does not list the number of data items in the table 50 51 instead, the number of items is Nsecfilt * Naverage. **/ 52 53 if (!gfits_scan (&catalog[0].header, "NSECFILT", "%d", 1, &Nsecfilt)) Nsecfilt = 0; 51 54 catalog[0].Nsecfilt = Nsecfilt; 52 53 /* default values, but we will assign these a valid value before we exit (even if empty) */ 54 catalog[0].average = NULL; 55 catalog[0].measure = NULL; 56 catalog[0].missing = NULL; 55 catalog[0].Nsecf_disk = Naverage * Nsecfilt; 57 56 catalog[0].secfilt = NULL; 58 catalog[0].lensing = NULL;59 catalog[0].lensobj = NULL;60 61 /* validate table mode ?*/62 57 63 58 /*** Average Table ***/ … … 259 254 } 260 255 256 /* read StarPar table header */ 257 if (!gfits_fread_header (catalog[0].f, &header)) { 258 if (VERBOSE) fprintf (stderr, "can't read table starpar header"); 259 return (FALSE); 260 } 261 /* read StarPar table data */ 262 if (catalog[0].catflags & LOAD_STARPAR) { 263 if (!gfits_fread_ftable_data (catalog[0].f, &ftable, FALSE)) { 264 if (VERBOSE) fprintf (stderr, "can't read table starpar data"); 265 return (FALSE); 266 } 267 catalog[0].starpar = FtableToStarPar (&ftable, &catalog[0].Nstarpar, &catalog[0].catformat); 268 if (Nstarpar != catalog[0].Nstarpar_disk) { 269 fprintf (stderr, "Warning: mismatch between Nstarpar in PHU and Table headers ("OFF_T_FMT" vs "OFF_T_FMT")\n", Nstarpar, catalog[0].Nstarpar_disk); 270 } 271 catalog[0].Nstarpar = catalog[0].Nstarpar_disk; 272 catalog[0].Nstarpar_off = 0; 273 } else { 274 Nbytes = gfits_data_size (&header); 275 fseeko (catalog[0].f, Nbytes, SEEK_CUR); 276 ALLOCATE (catalog[0].starpar, StarPar, 1); 277 catalog[0].Nstarpar = 0; 278 catalog[0].Nstarpar_off = catalog[0].Nstarpar_disk; 279 } 280 261 281 return (TRUE); 262 282 } … … 309 329 gfits_modify (&catalog[0].header, "NLENSING", OFF_T_FMT, 1, catalog[0].Nlensing); 310 330 gfits_modify (&catalog[0].header, "NLENSOBJ", OFF_T_FMT, 1, catalog[0].Nlensobj); 331 gfits_modify (&catalog[0].header, "NSTARPAR", OFF_T_FMT, 1, catalog[0].Nstarpar); 311 332 gfits_modify_alt (&catalog[0].header, "EXTEND", "%t", 1, TRUE); 312 333 gfits_modify (&catalog[0].header, "OBJID", "%d", 1, catalog[0].objID); … … 403 424 /* write out Lensobj table (convert to FITS table format) */ 404 425 LensobjToFtable (&ftable, catalog[0].lensobj, catalog[0].Nlensobj, catalog[0].catformat); 426 if (!gfits_fwrite_Theader (catalog[0].f, &header)) { 427 fprintf (stderr, "can't write table header"); 428 goto failure; 429 } 430 if (!gfits_fwrite_table (catalog[0].f, &ftable)) { 431 fprintf (stderr, "can't write table data"); 432 goto failure; 433 } 434 gfits_free_table (&ftable); 435 gfits_free_header (&header); 436 437 /* free temp storage */ 438 if (primary != NULL) { 439 free (primary); 440 free (secfilt); 441 } 442 return (TRUE); 443 444 /* write out StarPar table (convert to FITS table format) */ 445 StarParToFtable (&ftable, catalog[0].starpar, catalog[0].Nstarpar, catalog[0].catformat); 405 446 if (!gfits_fwrite_Theader (catalog[0].f, &header)) { 406 447 fprintf (stderr, "can't write table header"); … … 446 487 lensobj header 447 488 lensobj table 489 starpar header 490 starpar table 448 491 */ 449 492 -
trunk/Ohana/src/libdvo/src/dvo_catalog_raw.c
r37035 r37807 92 92 FORMAT_CASE (PS1_V5, PS1_V5); 93 93 FORMAT_CASE (PS1_REF, PS1_REF); 94 FORMAT_CASE (PS1_SIM, PS1_SIM); 94 95 95 96 default: … … 287 288 if (catalog[0].catformat == DVO_FORMAT_PS1_V5) gfits_modify (&catalog[0].header, "FORMAT", "%s", 1, "PS1_V5"); 288 289 if (catalog[0].catformat == DVO_FORMAT_PS1_REF) gfits_modify (&catalog[0].header, "FORMAT", "%s", 1, "PS1_REF"); 290 if (catalog[0].catformat == DVO_FORMAT_PS1_SIM) gfits_modify (&catalog[0].header, "FORMAT", "%s", 1, "PS1_SIM"); 289 291 290 292 /* rewind file pointers and truncate file */ … … 391 393 FORMAT_CASE (PS1_V5, PS1_V5); 392 394 FORMAT_CASE (PS1_REF, PS1_REF); 395 FORMAT_CASE (PS1_SIM, PS1_SIM); 393 396 394 397 default: … … 443 446 FORMAT_CASE (PS1_V5, PS1_V5); 444 447 FORMAT_CASE (PS1_REF, PS1_REF); 448 FORMAT_CASE (PS1_SIM, PS1_SIM); 445 449 446 450 default: … … 498 502 FORMAT_CASE (PS1_V5, PS1_V5); 499 503 FORMAT_CASE (PS1_REF, PS1_REF); 504 FORMAT_CASE (PS1_SIM, PS1_SIM); 500 505 501 506 default: … … 550 555 FORMAT_CASE (PS1_V5, PS1_V5); 551 556 FORMAT_CASE (PS1_REF, PS1_REF); 557 FORMAT_CASE (PS1_SIM, PS1_SIM); 552 558 553 559 default: … … 606 612 FORMAT_CASE (PS1_V5, PS1_V5); 607 613 FORMAT_CASE (PS1_REF, PS1_REF); 614 FORMAT_CASE (PS1_SIM, PS1_SIM); 608 615 609 616 default: … … 658 665 FORMAT_CASE (PS1_V5, PS1_V5); 659 666 FORMAT_CASE (PS1_REF, PS1_REF); 667 FORMAT_CASE (PS1_SIM, PS1_SIM); 660 668 661 669 default: -
trunk/Ohana/src/libdvo/src/dvo_catalog_split.c
r37035 r37807 75 75 Matrix matrix; 76 76 77 // ohana_memcheck_func (TRUE); 78 79 80 if (0) { 81 // XXX a TEST : is the data corrupted or the file? 82 char name[1024]; 83 snprintf (name, 1024, "%s.phu.v2", catalog->filename); 84 FILE *f = fopen (name, "w"); 85 fwrite (catalog->header.buffer, sizeof(char), catalog->header.datasize, f); 86 // fprintf (stderr, "save %d bytes in %s (%zx)\n", (int) catalog->header.datasize, name, (size_t) catalog->header.buffer); 87 // fprintf (stderr, "first bytes are %c%c%c%c%c%c%c%c\n", 88 // catalog->header.buffer[0], catalog->header.buffer[1], catalog->header.buffer[2], catalog->header.buffer[3], 89 // catalog->header.buffer[4], catalog->header.buffer[5], catalog->header.buffer[6], catalog->header.buffer[7]); 90 fclose (f); 91 } 92 if (0) { 93 // XXX a TEST : is the data corrupted or the file? 94 char name[1024]; 95 snprintf (name, 1024, "%s.phu", catalog->filename); 96 FILE *f = fopen (name, "w"); 97 fwrite (catalog->header.buffer, sizeof(char), catalog->header.datasize, f); 98 // fprintf (stderr, "save %d bytes in %s (%zx)\n", (int) catalog->header.datasize, name, (size_t) catalog->header.buffer); 99 // fprintf (stderr, "first bytes are %c%c%c%c%c%c%c%c\n", 100 // catalog->header.buffer[0], catalog->header.buffer[1], catalog->header.buffer[2], catalog->header.buffer[3], 101 // catalog->header.buffer[4], catalog->header.buffer[5], catalog->header.buffer[6], catalog->header.buffer[7]); 102 fclose (f); 103 } 104 # if (0) 105 { 106 // XXX a TEST : is the data corrupted or the file? 107 char name[1024]; 108 snprintf (name, 1024, "%s.phu.v2", catalog->filename); 109 FILE *f = fopen (name, "w"); 110 fwrite (catalog->header.buffer, sizeof(char), catalog->header.datasize, f); 111 fprintf (stderr, "save %d bytes in %s (%zx)\n", (int) catalog->header.datasize, name, (size_t) catalog->header.buffer); 112 fprintf (stderr, "first bytes are %c%c%c%c%c%c%c%c\n", 113 catalog->header.buffer[0], catalog->header.buffer[1], catalog->header.buffer[2], catalog->header.buffer[3], 114 catalog->header.buffer[4], catalog->header.buffer[5], catalog->header.buffer[6], catalog->header.buffer[7]); 115 fclose (f); 116 } 117 { 118 // XXX a TEST : is the data corrupted or the file? 119 char name[1024]; 120 snprintf (name, 1024, "%s.phu.v3", catalog->filename); 121 FILE *f = fopen (name, "w"); 122 fwrite (catalog->header.buffer, sizeof(char), catalog->header.datasize, f); 123 fprintf (stderr, "save %d bytes in %s (%zx)\n", (int) catalog->header.datasize, name, (size_t) catalog->header.buffer); 124 fprintf (stderr, "first bytes are %c%c%c%c%c%c%c%c\n", 125 catalog->header.buffer[0], catalog->header.buffer[1], catalog->header.buffer[2], catalog->header.buffer[3], 126 catalog->header.buffer[4], catalog->header.buffer[5], catalog->header.buffer[6], catalog->header.buffer[7]); 127 fclose (f); 128 } 129 # endif 77 130 /* rewind file pointers and truncate (file is still open) */ 78 fseeko (catalog->f, 0LL, SEEK_SET); 131 if (fseeko (catalog->f, 0LL, SEEK_SET)) { 132 perror ("dvo_catalog_save_subset: "); 133 fprintf (stderr, "failed to seek to beginning\n"); 134 } 79 135 80 136 // write PHU header … … 134 190 if (!gfits_scan (&catalog[0].header, name, "%s", 1, string)) { 135 191 free (path); 136 // databases created prior to ~2014.07.01 did not have the LENSING or LENSOBJpaths in their headers.192 // databases created prior to ~2014.07.01 did not have the LENSING, LENSOBJ, STARPAR paths in their headers. 137 193 // in these cases, we do not try to lock or open the relevant file 138 194 if (!strcmp (name, "LENSING")) return (DVO_CAT_OPEN_EMPTY); 139 195 if (!strcmp (name, "LENSOBJ")) return (DVO_CAT_OPEN_EMPTY); 196 if (!strcmp (name, "STARPAR")) return (DVO_CAT_OPEN_EMPTY); 140 197 return (DVO_CAT_OPEN_FAIL); 141 198 } … … 182 239 off_t Nlensing; 183 240 off_t Nlensobj; 241 off_t Nstarpar; 184 242 off_t Nitems; 185 243 int status, Nsecfilt; … … 196 254 197 255 /* get the components from the header - these duplicate information in the split files (NAXIS2) */ 198 // NSTARS, NMEAS, NMISS are required; NLENSING, NLENSOBJ are not (0 if not found)256 // NSTARS, NMEAS, NMISS are required; NLENSING, NLENSOBJ, NSTARPAR are not (0 if not found) 199 257 if (!gfits_scan (&catalog[0].header, "NSTARS", OFF_T_FMT, 1, &Naverage)) return (FALSE); 200 258 if (!gfits_scan (&catalog[0].header, "NMEAS", OFF_T_FMT, 1, &Nmeasure)) return (FALSE); … … 203 261 if (!gfits_scan (&catalog[0].header, "NLENSING", OFF_T_FMT, 1, &Nlensing)) Nlensing = 0; 204 262 if (!gfits_scan (&catalog[0].header, "NLENSOBJ", OFF_T_FMT, 1, &Nlensobj)) Nlensobj = 0; 263 if (!gfits_scan (&catalog[0].header, "NSTARPAR", OFF_T_FMT, 1, &Nstarpar)) Nstarpar = 0; 205 264 206 265 /* the OBJID is a counter that uniquely defines an average entry and never changes. if … … 223 282 catalog[0].Nlensing_disk = Nlensing; 224 283 catalog[0].Nlensobj_disk = Nlensobj; 284 catalog[0].Nstarpar_disk = Nstarpar; 225 285 226 286 /** Nsecfilt is unusual: it does not list the number of data items in the table … … 235 295 catalog[0].lensing = NULL; 236 296 catalog[0].lensobj = NULL; 297 catalog[0].starpar = NULL; 237 298 238 299 /*** Average Table ***/ … … 348 409 /*** Secfilt Table ***/ 349 410 status = dvo_catalog_open_subcat (catalog, &catalog[0].secfilt_catalog, ftable.header, "SECFILT", VERBOSE); 411 // fprintf (stderr, "secfilt header %s : %zx\n", catalog[0].secfilt_catalog[0].filename, (size_t) catalog[0].secfilt_catalog[0].header.buffer); 350 412 if (status == DVO_CAT_OPEN_FAIL) { 351 413 return (FALSE); … … 465 527 gfits_free_header (&header); 466 528 529 /*** StarPar Table ***/ 530 if (!(catalog[0].catflags & SKIP_STARPAR)) { 531 // unless we specify 'skip', we still need to load the 532 status = dvo_catalog_open_subcat (catalog, &catalog[0].starpar_catalog, ftable.header, "STARPAR", VERBOSE); 533 if (status == DVO_CAT_OPEN_FAIL) { 534 return (FALSE); 535 } 536 // the StarPar file need not exist, unless we expect data to exist 537 if ((status == DVO_CAT_OPEN_EMPTY) && (catalog[0].Nstarpar_disk > 0)) { 538 return (FALSE); 539 } 540 } 541 if ((status != DVO_CAT_OPEN_EMPTY) && (catalog[0].catflags & LOAD_STARPAR)) { 542 // only read the StarPar table if the file actually exists 543 /* read StarPar table data */ 544 if (!gfits_fread_ftable_data (catalog[0].starpar_catalog[0].f, &ftable, FALSE)) { 545 if (VERBOSE) fprintf (stderr, "can't read table starpar data\n"); 546 return (FALSE); 547 } 548 /* convert data format to internal : returns number of row read in Nstarpar */ 549 catalog[0].starpar = FtableToStarPar (&ftable, &Nstarpar, &catalog[0].catformat); 550 if (Nstarpar != catalog[0].Nstarpar_disk) { 551 fprintf (stderr, "Warning: mismatch between Nstarpar in PHU and Table headers ("OFF_T_FMT" vs "OFF_T_FMT")\n", Nstarpar, catalog[0].Nstarpar_disk); 552 } 553 catalog[0].Nstarpar = catalog[0].Nstarpar_disk; 554 catalog[0].Nstarpar_off = 0; 555 } else { 556 if (catalog[0].starpar_catalog) { 557 gfits_free_header (&catalog[0].starpar_catalog[0].header); 558 } else { 559 ALLOCATE (catalog[0].starpar_catalog, Catalog, 1); 560 dvo_catalog_init (catalog[0].starpar_catalog, TRUE); 561 } 562 gfits_create_header (&catalog[0].starpar_catalog[0].header); 563 ALLOCATE (catalog[0].starpar, StarPar, 1); 564 catalog[0].Nstarpar = 0; 565 catalog[0].Nstarpar_off = catalog[0].Nstarpar_disk; 566 } 567 gfits_free_header (&header); 568 467 569 return (TRUE); 468 570 } … … 473 575 474 576 off_t Nbytes; 475 off_t Naverage, Nexpect, Nitems, Nmeasure, Nmissing, Nlensing, Nlensobj ;577 off_t Naverage, Nexpect, Nitems, Nmeasure, Nmissing, Nlensing, Nlensobj, Nstarpar; 476 578 Header header; 477 579 FTable ftable; … … 497 599 } 498 600 /* read Average table data : format is irrelevant here */ 499 if (!gfits_fread_ftable_range (catalog[0].f, &ftable, start, Nrows)) {601 if (!gfits_fread_ftable_range (catalog[0].f, FALSE, &ftable, start, Nrows)) { 500 602 if (VERBOSE) fprintf (stderr, "can't read table average data"); 501 603 return (FALSE); … … 527 629 } 528 630 /* read Secfilt table data : format is irrelevant here */ 529 if (!gfits_fread_ftable_range (subcat[0].f, &ftable, start*catalog[0].Nsecfilt, catalog[0].Naverage*catalog[0].Nsecfilt)) {631 if (!gfits_fread_ftable_range (subcat[0].f, FALSE, &ftable, start*catalog[0].Nsecfilt, catalog[0].Naverage*catalog[0].Nsecfilt)) { 530 632 if (VERBOSE) fprintf (stderr, "can't read table measure data"); 531 633 return (FALSE); … … 563 665 } 564 666 /* read Measure table data : format is irrelevant here */ 565 if (!gfits_fread_ftable_range (subcat[0].f, &ftable, start, Nrows)) {667 if (!gfits_fread_ftable_range (subcat[0].f, FALSE, &ftable, start, Nrows)) { 566 668 if (VERBOSE) fprintf (stderr, "can't read table measure data"); 567 669 return (FALSE); … … 594 696 } 595 697 /* read Missing table data : format is irrelevant here */ 596 if (!gfits_fread_ftable_range (subcat[0].f, &ftable, start, Nrows)) {698 if (!gfits_fread_ftable_range (subcat[0].f, FALSE, &ftable, start, Nrows)) { 597 699 if (VERBOSE) fprintf (stderr, "can't read table missing data"); 598 700 return (FALSE); … … 628 730 } 629 731 /* read Lensing table data : format is irrelevant here */ 630 if (!gfits_fread_ftable_range (subcat[0].f, &ftable, start, Nrows)) {732 if (!gfits_fread_ftable_range (subcat[0].f, FALSE, &ftable, start, Nrows)) { 631 733 if (VERBOSE) fprintf (stderr, "can't read table lensing data"); 632 734 return (FALSE); … … 659 761 } 660 762 /* read Lensobj table data : format is irrelevant here */ 661 if (!gfits_fread_ftable_range (subcat[0].f, &ftable, start, Nrows)) {763 if (!gfits_fread_ftable_range (subcat[0].f, FALSE, &ftable, start, Nrows)) { 662 764 if (VERBOSE) fprintf (stderr, "can't read table lensobj data"); 663 765 return (FALSE); … … 675 777 } 676 778 779 // XXX check the open status of the catalog 780 if (catalog[0].catflags & LOAD_STARPAR) { 781 782 Catalog *subcat = catalog[0].starpar_catalog; 783 784 /* move pointer past header -- must be already read (load_catalog) */ 785 Nbytes = subcat[0].header.datasize + gfits_data_size (&subcat[0].header); 786 fseeko (subcat[0].f, Nbytes, SEEK_SET); 787 788 /* read StarPar table header */ 789 if (!gfits_fread_header (subcat[0].f, &header)) { 790 if (VERBOSE) fprintf (stderr, "can't read table starpar header"); 791 return (FALSE); 792 } 793 /* read StarPar table data : format is irrelevant here */ 794 if (!gfits_fread_ftable_range (subcat[0].f, FALSE, &ftable, start, Nrows)) { 795 if (VERBOSE) fprintf (stderr, "can't read table starpar data"); 796 return (FALSE); 797 } 798 799 /* convert data format to internal : returns number of row read in Nstarpar */ 800 catalog[0].starpar = FtableToStarPar (&ftable, &Nstarpar, &catalog[0].catformat); 801 if (Nstarpar != Nrows) { 802 // XXX this condition denotes the eof has been reached; not an error or a warning 803 // fprintf (stderr, "Warning: mismatch between Nstarpar in PHU and Table headers ("OFF_T_FMT" vs "OFF_T_FMT")\n", Nstarpar, Nrows); 804 } 805 gfits_free_header (&header); 806 catalog[0].Nstarpar = Nstarpar; 807 catalog[0].Nstarpar_off = start; 808 } 809 677 810 return (TRUE); 678 811 } … … 686 819 SecFilt *primary, *secfilt; 687 820 int Nsecfilt; 688 off_t Naves_disk_new, Nmeas_disk_new, Nmiss_disk_new, Nsecf_disk_new, Nlensing_disk_new, Nlensobj_disk_new ;821 off_t Naves_disk_new, Nmeas_disk_new, Nmiss_disk_new, Nsecf_disk_new, Nlensing_disk_new, Nlensobj_disk_new, Nstarpar_disk_new; 689 822 off_t first, start, Nrows; 690 823 … … 719 852 Nlensing_disk_new = MAX (catalog[0].Nlensing_disk, catalog[0].Nlensing + catalog[0].Nlensing_off); 720 853 Nlensobj_disk_new = MAX (catalog[0].Nlensobj_disk, catalog[0].Nlensobj + catalog[0].Nlensobj_off); 854 Nstarpar_disk_new = MAX (catalog[0].Nstarpar_disk, catalog[0].Nstarpar + catalog[0].Nstarpar_off); 721 855 722 856 /* make sure header is consistent with data */ … … 727 861 gfits_modify (&catalog[0].header, "NLENSING", OFF_T_FMT, 1, Nlensing_disk_new); 728 862 gfits_modify (&catalog[0].header, "NLENSOBJ", OFF_T_FMT, 1, Nlensobj_disk_new); 863 gfits_modify (&catalog[0].header, "NSTARPAR", OFF_T_FMT, 1, Nstarpar_disk_new); 729 864 gfits_modify_alt (&catalog[0].header, "EXTEND", "%t", 1, TRUE); 730 865 gfits_modify (&catalog[0].header, "OBJID", "%d", 1, catalog[0].objID); … … 845 980 } 846 981 847 /*** Lensing Table ***/848 if ((catalog[0].catflags & LOAD_LENSING) && (catalog[0].lensing != NULL)) {982 /*** Lensing Table (optional, do not save if not loaded) ***/ 983 if ((catalog[0].catflags & LOAD_LENSING) && catalog[0].lensing_catalog->f && catalog[0].lensing) { 849 984 850 985 first = 0; // first row in memory to write … … 872 1007 } 873 1008 874 /*** Lensobj Table ***/875 if ((catalog[0].catflags & LOAD_LENSOBJ) && (catalog[0].lensobj != NULL)) {1009 /*** Lensobj Table (optional, do not save if not loaded) ***/ 1010 if ((catalog[0].catflags & LOAD_LENSOBJ) && catalog[0].lensobj_catalog->f && catalog[0].lensobj) { 876 1011 877 1012 first = 0; // first row in memory to write … … 893 1028 if (!dvo_catalog_save_subcat (catalog[0].lensobj_catalog, &ftable, start, Nrows, catalog[0].Nlensobj_disk, Nlensobj_disk_new)) { 894 1029 fprintf (stderr, "trouble writing Lensobj table\n"); 1030 goto failure; 1031 } 1032 gfits_free_header (&header); 1033 gfits_free_table (&ftable); 1034 } 1035 1036 /*** StarPar Table (optional, do not save if not loaded) ***/ 1037 if ((catalog[0].catflags & LOAD_STARPAR) && catalog[0].starpar_catalog->f && catalog[0].starpar) { 1038 1039 first = 0; // first row in memory to write 1040 start = catalog[0].Nstarpar_off; // first disk row to write 1041 Nrows = catalog[0].Nstarpar - first; 1042 1043 assert (Nrows >= 0); 1044 assert (first >= 0); 1045 assert (first <= catalog[0].Nstarpar); 1046 assert (catalog[0].Nstarpar_disk >= catalog[0].Nstarpar_off); 1047 1048 // convert to external table format (note that the block above does not damage or free catalog.average) 1049 if (!StarParToFtable (&ftable, &catalog[0].starpar[first], Nrows, catalog[0].catformat)) { 1050 fprintf (stderr, "trouble converting format\n"); 1051 goto failure; 1052 } 1053 1054 // write out StarPar table 1055 if (!dvo_catalog_save_subcat (catalog[0].starpar_catalog, &ftable, start, Nrows, catalog[0].Nstarpar_disk, Nstarpar_disk_new)) { 1056 fprintf (stderr, "trouble writing StarPar table\n"); 895 1057 goto failure; 896 1058 } … … 925 1087 SecFilt *primary, *secfilt; 926 1088 int Nsecfilt; 927 off_t Naves_disk_new, Nmeas_disk_new, Nmiss_disk_new, Nsecf_disk_new, Nlensing_disk_new, Nlensobj_disk_new ;1089 off_t Naves_disk_new, Nmeas_disk_new, Nmiss_disk_new, Nsecf_disk_new, Nlensing_disk_new, Nlensobj_disk_new, Nstarpar_disk_new; 928 1090 off_t first, start, Nrows; 929 1091 … … 956 1118 if (catalog[0].Nlensobj_off > 0) { 957 1119 fprintf (stderr, "ERROR: only partial catalog (Lensobj) was loaded\n"); 1120 goto failure; 1121 } 1122 if (catalog[0].Nstarpar_off > 0) { 1123 fprintf (stderr, "ERROR: only partial catalog (StarPar) was loaded\n"); 958 1124 goto failure; 959 1125 } … … 984 1150 Nlensing_disk_new = catalog[0].Nlensing; 985 1151 Nlensobj_disk_new = catalog[0].Nlensobj; 1152 Nstarpar_disk_new = catalog[0].Nstarpar; 986 1153 987 1154 /* make sure header is consistent with data */ … … 992 1159 gfits_modify (&catalog[0].header, "NLENSING", OFF_T_FMT, 1, Nlensing_disk_new); 993 1160 gfits_modify (&catalog[0].header, "NLENSOBJ", OFF_T_FMT, 1, Nlensobj_disk_new); 1161 gfits_modify (&catalog[0].header, "NSTARPAR", OFF_T_FMT, 1, Nstarpar_disk_new); 994 1162 gfits_modify_alt (&catalog[0].header, "EXTEND", "%t", 1, TRUE); 995 1163 gfits_modify (&catalog[0].header, "OBJID", "%d", 1, catalog[0].objID); … … 1158 1326 if (!dvo_catalog_save_subcat (catalog[0].lensobj_catalog, &ftable, start, Nrows, catalog[0].Nlensobj_disk, Nlensobj_disk_new)) { 1159 1327 fprintf (stderr, "trouble writing Lensobj table\n"); 1328 goto failure; 1329 } 1330 gfits_free_header (&header); 1331 gfits_free_table (&ftable); 1332 } 1333 1334 /*** StarPar Table ***/ 1335 if ((catalog[0].catflags & LOAD_STARPAR) && (catalog[0].starpar != NULL)) { 1336 1337 first = 0; // first row in memory to write 1338 start = catalog[0].Nstarpar_off; // first disk row to write 1339 Nrows = catalog[0].Nstarpar - first; 1340 1341 assert (Nrows >= 0); 1342 assert (first >= 0); 1343 assert (first <= catalog[0].Nstarpar); 1344 assert (catalog[0].Nstarpar_disk >= catalog[0].Nstarpar_off); 1345 1346 // convert to external table format 1347 if (!StarParToFtable (&ftable, &catalog[0].starpar[first], Nrows, catalog[0].catformat)) { 1348 fprintf (stderr, "trouble converting format\n"); 1349 goto failure; 1350 } 1351 1352 // write out StarPar table 1353 if (!dvo_catalog_save_subcat (catalog[0].starpar_catalog, &ftable, start, Nrows, catalog[0].Nstarpar_disk, Nstarpar_disk_new)) { 1354 fprintf (stderr, "trouble writing StarPar table\n"); 1160 1355 goto failure; 1161 1356 } … … 1189 1384 SecFilt *primary, *secfilt; 1190 1385 int Nsecfilt; 1191 off_t Naves_disk_new, Nmeas_disk_new, Nmiss_disk_new, Nsecf_disk_new, Nlensing_disk_new, Nlensobj_disk_new ;1386 off_t Naves_disk_new, Nmeas_disk_new, Nmiss_disk_new, Nsecf_disk_new, Nlensing_disk_new, Nlensobj_disk_new, Nstarpar_disk_new; 1192 1387 off_t first, start, Nrows; 1193 1388 … … 1221 1416 Nlensing_disk_new = MAX (catalog[0].Nlensing_disk, catalog[0].Nlensing + catalog[0].Nlensing_off); 1222 1417 Nlensobj_disk_new = MAX (catalog[0].Nlensobj_disk, catalog[0].Nlensobj + catalog[0].Nlensobj_off); 1418 Nstarpar_disk_new = MAX (catalog[0].Nstarpar_disk, catalog[0].Nstarpar + catalog[0].Nstarpar_off); 1223 1419 1224 1420 /* make sure header is consistent with data */ … … 1229 1425 gfits_modify (&catalog[0].header, "NLENSING", OFF_T_FMT, 1, Nlensing_disk_new); 1230 1426 gfits_modify (&catalog[0].header, "NLENSOBJ", OFF_T_FMT, 1, Nlensobj_disk_new); 1427 gfits_modify (&catalog[0].header, "NSTARPAR", OFF_T_FMT, 1, Nstarpar_disk_new); 1231 1428 gfits_modify_alt (&catalog[0].header, "EXTEND", "%t", 1, TRUE); 1232 1429 gfits_modify (&catalog[0].header, "OBJID", "%d", 1, catalog[0].objID); … … 1399 1596 if (!dvo_catalog_save_subcat (catalog[0].lensobj_catalog, &ftable, start, Nrows, catalog[0].Nlensobj_disk, Nlensobj_disk_new)) { 1400 1597 fprintf (stderr, "trouble writing Lensobj table\n"); 1598 goto failure; 1599 } 1600 gfits_free_header (&header); 1601 gfits_free_table (&ftable); 1602 } 1603 1604 /*** StarPar Table ***/ 1605 if (catalog[0].starpar != NULL) { 1606 1607 first = catalog[0].Nstarpar_disk - catalog[0].Nstarpar_off; // first row in memory to write 1608 start = catalog[0].Nstarpar_disk; // first disk row to write 1609 Nrows = catalog[0].Nstarpar - first; 1610 1611 assert (Nrows >= 0); 1612 assert (first >= 0); 1613 assert (first <= catalog[0].Nstarpar); 1614 assert (catalog[0].Nstarpar_disk >= catalog[0].Nstarpar_off); 1615 1616 // convert to external table format 1617 // XXX does catalog.starpar have averef correctly set up? 1618 if (!StarParToFtable (&ftable, &catalog[0].starpar[first], Nrows, catalog[0].catformat)) { 1619 fprintf (stderr, "trouble converting format\n"); 1620 goto failure; 1621 } 1622 1623 // write out StarPar table 1624 if (!dvo_catalog_save_subcat (catalog[0].starpar_catalog, &ftable, start, Nrows, catalog[0].Nstarpar_disk, Nstarpar_disk_new)) { 1625 fprintf (stderr, "trouble writing StarPar table\n"); 1401 1626 goto failure; 1402 1627 } -
trunk/Ohana/src/libdvo/src/dvo_convert.c
r37246 r37807 43 43 CONVERT_FORMAT ("DVO_AVERAGE_PS1_V5", PS1_V5); 44 44 CONVERT_FORMAT ("DVO_AVERAGE_PS1_REF", PS1_REF); 45 CONVERT_FORMAT ("DVO_AVERAGE_PS1_SIM", PS1_SIM); 45 46 # undef CONVERT_FORMAT 46 47 … … 129 130 CONVERT_FORMAT ("DVO_AVERAGE_PS1_V5", PS1_V5, PS1_V5); 130 131 CONVERT_FORMAT ("DVO_AVERAGE_PS1_REF", PS1_REF, PS1_REF); 132 CONVERT_FORMAT ("DVO_AVERAGE_PS1_SIM", PS1_SIM, PS1_SIM); 131 133 # undef CONVERT_FORMAT 132 134 … … 165 167 FORMAT_CASE (PS1_V5, PS1_V5); 166 168 FORMAT_CASE (PS1_REF, PS1_REF); 169 FORMAT_CASE (PS1_SIM, PS1_SIM); 167 170 # undef FORMAT_CASE 168 171 … … 240 243 CONVERT_FORMAT ("DVO_MEASURE_PS1_V5", PS1_V5, PS1_V5, TRUE); 241 244 CONVERT_FORMAT ("DVO_MEASURE_PS1_REF", PS1_REF, PS1_REF, FALSE); 245 CONVERT_FORMAT ("DVO_MEASURE_PS1_SIM", PS1_SIM, PS1_SIM, TRUE); 242 246 # undef CONVERT_FORMAT 243 247 … … 254 258 case DVO_FORMAT_##FORMAT: { \ 255 259 Measure_##TYPE *tmpMeasure; \ 256 myAssert (ABS_COORDS || average, "conversion tointernal needs average table"); \260 myAssert (ABS_COORDS || average, "conversion from internal needs average table"); \ 257 261 tmpMeasure = MeasureInternalTo_##TYPE (average, measure, Nmeasure); \ 258 262 gfits_table_set_Measure_##TYPE (ftable, tmpMeasure, Nmeasure); \ … … 278 282 FORMAT_CASE (PS1_V5, PS1_V5, TRUE); 279 283 FORMAT_CASE (PS1_REF, PS1_REF, FALSE); 284 FORMAT_CASE (PS1_SIM, PS1_SIM, TRUE); 280 285 # undef FORMAT_CASE 281 286 … … 350 355 CONVERT_FORMAT ("DVO_SECFILT_PS1_V5", PS1_V5, PS1_V5); 351 356 CONVERT_FORMAT ("DVO_SECFILT_PS1_REF", PS1_REF, PS1_REF); 357 CONVERT_FORMAT ("DVO_SECFILT_PS1_SIM", PS1_SIM, PS1_SIM); 352 358 # undef CONVERT_FORMAT 353 359 … … 386 392 FORMAT_CASE (PS1_V5, PS1_V5); 387 393 FORMAT_CASE (PS1_REF, PS1_REF); 394 FORMAT_CASE (PS1_SIM, PS1_SIM); 388 395 # undef FORMAT_CASE 389 396 … … 407 414 return (FALSE); 408 415 } 416 417 if (!strcmp (extname, "DVO_LENSING_PS1_V5") && (ftable[0].header[0].Naxis[0] == 128)) { 418 Lensing_PS1_V5_ALT *tmpLensing; 419 tmpLensing = gfits_table_get_Lensing_PS1_V5_ALT (ftable, Nlensing, NULL); 420 if (!tmpLensing) { 421 fprintf (stderr, "ERROR: failed to read lensings\n"); 422 exit (2); 423 } 424 lensing = Lensing_PS1_V5_ALT_ToInternal (tmpLensing, *Nlensing); 425 free (tmpLensing); 426 *format = DVO_FORMAT_PS1_V5; 427 return (lensing); } 409 428 410 429 # define CONVERT_FORMAT(NAME, FORMAT, TYPE) \ … … 585 604 default: 586 605 fprintf (stderr, "table format unknown (lensobj)\n"); 606 return (FALSE); 607 } 608 return (TRUE); 609 } 610 611 /*** StarPar / FTable conversion functions ***/ 612 613 StarPar *FtableToStarPar (FTable *ftable, off_t *Nstarpar, char *format) { 614 615 StarPar *starpar; 616 char extname[80]; 617 618 /* convert to the internal format */ 619 if (!gfits_scan (ftable[0].header, "EXTNAME", "%s", 1, extname)) { 620 fprintf (stderr, "EXTNAME missing for starpar table\n"); 621 return (FALSE); 622 } 623 624 # define CONVERT_FORMAT(NAME, FORMAT, TYPE) \ 625 if (!strcmp (extname, NAME)) { \ 626 StarPar_##TYPE *tmpStarPar; \ 627 tmpStarPar = gfits_table_get_StarPar_##TYPE (ftable, Nstarpar, NULL); \ 628 if (!tmpStarPar) { \ 629 fprintf (stderr, "ERROR: failed to read starpar\n"); \ 630 exit (2); \ 631 } \ 632 starpar = StarPar_##TYPE##_ToInternal (tmpStarPar, *Nstarpar); \ 633 free (tmpStarPar); \ 634 *format = DVO_FORMAT_##FORMAT; \ 635 return (starpar); } 636 637 if (!strcmp (extname, "DVO_STARPAR")) { 638 starpar = gfits_table_get_StarPar (ftable, Nstarpar, NULL); 639 if (!starpar) { 640 fprintf (stderr, "ERROR: failed to read starpar\n"); 641 exit (2); 642 } 643 *format = DVO_FORMAT_INTERNAL; 644 return (starpar); 645 } 646 647 CONVERT_FORMAT ("DVO_STARPAR_PS1_SIM", PS1_SIM, PS1_SIM); 648 // CONVERT_FORMAT ("DVO_STARPAR_PS1_REF", PS1_REF, PS1_REF); 649 // CONVERT_FORMAT ("DVO_STARPAR_ELIXIR", ELIXIR, Elixir); 650 // CONVERT_FORMAT ("DVO_STARPAR_LONEOS", LONEOS, Loneos); 651 // CONVERT_FORMAT ("DVO_STARPAR_PANSTARRS_DEV_0", PANSTARRS_DEV_0, Panstarrs_DEV_0); 652 // CONVERT_FORMAT ("DVO_STARPAR_PANSTARRS_DEV_1", PANSTARRS_DEV_1, Panstarrs_DEV_1); 653 // CONVERT_FORMAT ("DVO_STARPAR_PS1_DEV_1", PS1_DEV_1, PS1_DEV_1); 654 // CONVERT_FORMAT ("DVO_STARPAR_PS1_DEV_2", PS1_DEV_2, PS1_DEV_2); 655 // CONVERT_FORMAT ("DVO_STARPAR_PS1_V1", PS1_V1, PS1_V1); 656 // CONVERT_FORMAT ("DVO_STARPAR_PS1_V2", PS1_V2, PS1_V2); 657 // CONVERT_FORMAT ("DVO_STARPAR_PS1_V3", PS1_V3, PS1_V3); 658 // CONVERT_FORMAT ("DVO_STARPAR_PS1_V4", PS1_V4, PS1_V4); 659 CONVERT_FORMAT ("DVO_STARPAR_PS1_V5", PS1_V5, PS1_V5); 660 // CONVERT_FORMAT ("DVO_STELLAR_PARAMS_PS1_V5", PS1_V5, PS1_V5); 661 // XXX fix in libauto: STELLAR_PARAMS to STARPAR 662 # undef CONVERT_FORMAT 663 664 fprintf (stderr, "table format unknown: %s\n", extname); 665 666 *Nstarpar = 0; 667 return (NULL); 668 } 669 670 // StarParToFtable needs the Average since old formats stored starpar.dR,dD only 671 int StarParToFtable (FTable *ftable, StarPar *starpar, off_t Nstarpar, char format) { 672 673 # define FORMAT_CASE(FORMAT, TYPE) \ 674 case DVO_FORMAT_##FORMAT: { \ 675 StarPar_##TYPE *tmpStarPar; \ 676 tmpStarPar = StarParInternalTo_##TYPE (starpar, Nstarpar); \ 677 gfits_table_set_StarPar_##TYPE (ftable, tmpStarPar, Nstarpar); \ 678 free (tmpStarPar); \ 679 break; } 680 681 /* convert from the internal format */ 682 switch (format) { 683 case DVO_FORMAT_INTERNAL: { 684 gfits_table_set_StarPar (ftable, starpar, Nstarpar); 685 break; } 686 687 FORMAT_CASE (PS1_SIM, PS1_SIM); 688 // FORMAT_CASE (PS1_REF, PS1_REF); 689 // FORMAT_CASE (ELIXIR, Elixir); 690 // FORMAT_CASE (LONEOS, Loneos); 691 // FORMAT_CASE (PANSTARRS_DEV_0, Panstarrs_DEV_0); 692 // FORMAT_CASE (PANSTARRS_DEV_1, Panstarrs_DEV_1); 693 // FORMAT_CASE (PS1_DEV_1, PS1_DEV_1); 694 // FORMAT_CASE (PS1_DEV_2, PS1_DEV_2); 695 // FORMAT_CASE (PS1_V1, PS1_V1); 696 // FORMAT_CASE (PS1_V2, PS1_V2); 697 // FORMAT_CASE (PS1_V3, PS1_V3); 698 // FORMAT_CASE (PS1_V4, PS1_V4); 699 FORMAT_CASE (PS1_V5, PS1_V5); 700 # undef FORMAT_CASE 701 702 default: 703 fprintf (stderr, "table format unknown (starpar)\n"); 587 704 return (FALSE); 588 705 } … … 643 760 return (TRUE); } 644 761 645 if (!strcmp (extname, "DVO_IMAGE")) {646 Image *image;647 image = gfits_table_get_Image (ftable, &Nimage, NULL);648 if (!image) {649 fprintf (stderr, "ERROR: failed to read images\n");650 exit (2);651 }652 *format = DVO_FORMAT_INTERNAL;653 return (TRUE);654 }655 656 762 CONVERT_FORMAT ("DVO_IMAGE_ELIXIR", ELIXIR, Elixir); 657 763 CONVERT_FORMAT ("DVO_IMAGE_LONEOS", LONEOS, Loneos); … … 666 772 CONVERT_FORMAT ("DVO_IMAGE_PS1_V5", PS1_V5, PS1_V5); 667 773 CONVERT_FORMAT ("DVO_IMAGE_PS1_REF", PS1_REF, PS1_REF); 774 CONVERT_FORMAT ("DVO_IMAGE_PS1_SIM", PS1_SIM, PS1_SIM); 668 775 669 776 # undef CONVERT_FORMAT … … 690 797 /* convert from the internal format */ 691 798 switch (format) { 692 case DVO_FORMAT_INTERNAL: {693 gfits_convert_Image ((Image *) ftable[0].buffer, sizeof(Image), Nimage);694 break; }695 696 799 FORMAT_CASE (ELIXIR, Elixir); 697 800 FORMAT_CASE (LONEOS, Loneos); … … 706 809 FORMAT_CASE (PS1_V5, PS1_V5); 707 810 FORMAT_CASE (PS1_REF, PS1_REF); 811 FORMAT_CASE (PS1_SIM, PS1_SIM); 708 812 709 813 # undef FORMAT_CASE … … 744 848 /* convert from the internal format */ 745 849 switch (format) { 746 case DVO_FORMAT_INTERNAL: {747 for (i = 0; i < Nrow; i++) {748 gfits_convert_Image ((Image *) vtable[0].buffer[i], sizeof(Image), 1);749 }750 return (TRUE); }751 752 850 FORMAT_CASE (ELIXIR, Elixir); 753 851 FORMAT_CASE (LONEOS, Loneos); … … 762 860 FORMAT_CASE (PS1_V5, PS1_V5); 763 861 FORMAT_CASE (PS1_REF, PS1_REF); 862 FORMAT_CASE (PS1_SIM, PS1_SIM); 764 863 765 864 # undef FORMAT_CASE -
trunk/Ohana/src/libdvo/src/dvo_convert_PS1_DEV_1.c
r37246 r37807 219 219 220 220 for (i = 0; i < Nvalues; i++) { 221 memcpy (&out[i].coords, &in[i].coords, sizeof(Coords)); 221 // this is only safe because the initial 120 bytes in Coords match CoordsDisk 222 memcpy (&out[i].coords, &in[i].coords, sizeof(CoordsDisk)); 223 out[i].coords.mosaic = NULL; 224 out[i].coords.offsetMap = NULL; 222 225 223 226 // RAW_IMAGE_NAME_LEN < DVO_IMAGE_NAME_LEN … … 287 290 288 291 for (i = 0; i < Nvalues; i++) { 289 memcpy (&out[i].coords, &in[i].coords, sizeof(Coords)); 292 // this is only safe because the initial 120 bytes in Coords match CoordsDisk 293 memcpy (&out[i].coords, &in[i].coords, sizeof(CoordsDisk)); 290 294 291 295 // RAW_IMAGE_NAME_LEN < DVO_IMAGE_NAME_LEN -
trunk/Ohana/src/libdvo/src/dvo_convert_PS1_DEV_2.c
r37246 r37807 214 214 215 215 for (i = 0; i < Nvalues; i++) { 216 memcpy (&out[i].coords, &in[i].coords, sizeof(Coords)); 216 // this is only safe because the initial 120 bytes in Coords match CoordsDisk 217 memcpy (&out[i].coords, &in[i].coords, sizeof(CoordsDisk)); 218 out[i].coords.mosaic = NULL; 219 out[i].coords.offsetMap = NULL; 217 220 218 221 // RAW_IMAGE_NAME_LEN < DVO_IMAGE_NAME_LEN … … 279 282 280 283 for (i = 0; i < Nvalues; i++) { 281 memcpy (&out[i].coords, &in[i].coords, sizeof(Coords)); 284 // this is only safe because the initial 120 bytes in Coords match CoordsDisk 285 memcpy (&out[i].coords, &in[i].coords, sizeof(CoordsDisk)); 282 286 283 287 // RAW_IMAGE_NAME_LEN < DVO_IMAGE_NAME_LEN -
trunk/Ohana/src/libdvo/src/dvo_convert_PS1_DEV_3.c
r37055 r37807 18 18 19 19 for (i = 0; i < Nvalues; i++) { 20 memcpy (&out[i].coords, &in[i].coords, sizeof(Coords)); 20 // this is only safe because the initial 120 bytes in Coords match CoordsDisk 21 memcpy (&out[i].coords, &in[i].coords, sizeof(CoordsDisk)); 22 out[i].coords.mosaic = NULL; 23 out[i].coords.offsetMap = NULL; 21 24 22 25 // RAW_IMAGE_NAME_LEN > DVO_IMAGE_NAME_LEN … … 78 81 79 82 for (i = 0; i < Nvalues; i++) { 80 memcpy (&out[i].coords, &in[i].coords, sizeof(Coords)); 83 // this is only safe because the initial 120 bytes in Coords match CoordsDisk 84 memcpy (&out[i].coords, &in[i].coords, sizeof(CoordsDisk)); 81 85 82 86 // RAW_IMAGE_NAME_LEN > DVO_IMAGE_NAME_LEN -
trunk/Ohana/src/libdvo/src/dvo_convert_PS1_REF.c
r37035 r37807 145 145 146 146 for (i = 0; i < Nvalues; i++) { 147 memcpy (&out[i].coords, &in[i].coords, sizeof(Coords)); 147 // this is only safe because the initial 120 bytes in Coords match CoordsDisk 148 memcpy (&out[i].coords, &in[i].coords, sizeof(CoordsDisk)); 149 out[i].coords.mosaic = NULL; 150 out[i].coords.offsetMap = NULL; 148 151 149 152 // RAW_IMAGE_NAME_LEN > DVO_IMAGE_NAME_LEN … … 208 211 209 212 for (i = 0; i < Nvalues; i++) { 210 memcpy (&out[i].coords, &in[i].coords, sizeof(Coords)); 213 // this is only safe because the initial 120 bytes in Coords match CoordsDisk 214 memcpy (&out[i].coords, &in[i].coords, sizeof(CoordsDisk)); 211 215 212 216 // RAW_IMAGE_NAME_LEN > DVO_IMAGE_NAME_LEN -
trunk/Ohana/src/libdvo/src/dvo_convert_PS1_V1.c
r37246 r37807 238 238 239 239 for (i = 0; i < Nvalues; i++) { 240 memcpy (&out[i].coords, &in[i].coords, sizeof(Coords)); 240 // this is only safe because the initial 120 bytes in Coords match CoordsDisk 241 memcpy (&out[i].coords, &in[i].coords, sizeof(CoordsDisk)); 242 out[i].coords.mosaic = NULL; 243 out[i].coords.offsetMap = NULL; 241 244 242 245 // RAW_IMAGE_NAME_LEN > DVO_IMAGE_NAME_LEN … … 302 305 303 306 for (i = 0; i < Nvalues; i++) { 304 memcpy (&out[i].coords, &in[i].coords, sizeof(Coords)); 307 // this is only safe because the initial 120 bytes in Coords match CoordsDisk 308 memcpy (&out[i].coords, &in[i].coords, sizeof(CoordsDisk)); 305 309 306 310 // RAW_IMAGE_NAME_LEN > DVO_IMAGE_NAME_LEN -
trunk/Ohana/src/libdvo/src/dvo_convert_PS1_V2.c
r37246 r37807 249 249 250 250 for (i = 0; i < Nvalues; i++) { 251 memcpy (&out[i].coords, &in[i].coords, sizeof(Coords)); 251 // this is only safe because the initial 120 bytes in Coords match CoordsDisk 252 memcpy (&out[i].coords, &in[i].coords, sizeof(CoordsDisk)); 253 out[i].coords.mosaic = NULL; 254 out[i].coords.offsetMap = NULL; 252 255 253 256 // RAW_IMAGE_NAME_LEN > DVO_IMAGE_NAME_LEN … … 313 316 314 317 for (i = 0; i < Nvalues; i++) { 315 memcpy (&out[i].coords, &in[i].coords, sizeof(Coords)); 318 // this is only safe because the initial 120 bytes in Coords match CoordsDisk 319 memcpy (&out[i].coords, &in[i].coords, sizeof(CoordsDisk)); 316 320 317 321 // RAW_IMAGE_NAME_LEN > DVO_IMAGE_NAME_LEN -
trunk/Ohana/src/libdvo/src/dvo_convert_PS1_V3.c
r37246 r37807 259 259 260 260 for (i = 0; i < Nvalues; i++) { 261 memcpy (&out[i].coords, &in[i].coords, sizeof(Coords)); 261 // this is only safe because the initial 120 bytes in Coords match CoordsDisk 262 memcpy (&out[i].coords, &in[i].coords, sizeof(CoordsDisk)); 263 out[i].coords.mosaic = NULL; 264 out[i].coords.offsetMap = NULL; 262 265 263 266 // RAW_IMAGE_NAME_LEN > DVO_IMAGE_NAME_LEN … … 323 326 324 327 for (i = 0; i < Nvalues; i++) { 325 memcpy (&out[i].coords, &in[i].coords, sizeof(Coords)); 328 // this is only safe because the initial 120 bytes in Coords match CoordsDisk 329 memcpy (&out[i].coords, &in[i].coords, sizeof(CoordsDisk)); 326 330 327 331 // RAW_IMAGE_NAME_LEN > DVO_IMAGE_NAME_LEN -
trunk/Ohana/src/libdvo/src/dvo_convert_PS1_V4.c
r37246 r37807 299 299 300 300 for (i = 0; i < Nvalues; i++) { 301 memcpy (&out[i].coords, &in[i].coords, sizeof(Coords)); 301 // this is only save because the initial 120 bytes in Coords match CoordsDisk 302 memcpy (&out[i].coords, &in[i].coords, sizeof(CoordsDisk)); 303 out[i].coords.mosaic = NULL; 304 out[i].coords.offsetMap = NULL; 302 305 303 306 // RAW_IMAGE_NAME_LEN > DVO_IMAGE_NAME_LEN … … 363 366 364 367 for (i = 0; i < Nvalues; i++) { 365 memcpy (&out[i].coords, &in[i].coords, sizeof(Coords)); 368 // this is only save because the initial 120 bytes in Coords match CoordsDisk 369 memcpy (&out[i].coords, &in[i].coords, sizeof(CoordsDisk)); 366 370 367 371 // RAW_IMAGE_NAME_LEN > DVO_IMAGE_NAME_LEN -
trunk/Ohana/src/libdvo/src/dvo_convert_PS1_V5.c
r37356 r37807 191 191 out[i].Nlensing = in[i].Nlensing; 192 192 out[i].Nlensobj = in[i].Nlensobj; 193 out[i].Nstarpar = in[i].Nstarpar; 193 194 out[i].Nextend = in[i].Nextend; 194 195 … … 197 198 out[i].lensingOffset = in[i].lensingOffset; 198 199 out[i].lensobjOffset = in[i].lensobjOffset; 200 out[i].starparOffset = in[i].starparOffset; 199 201 out[i].extendOffset = in[i].extendOffset; 200 out[i].paramsOffset = in[i].paramsOffset;201 202 202 203 out[i].refColorBlue = in[i].refColorBlue; … … 258 259 out[i].Nlensing = in[i].Nlensing; 259 260 out[i].Nlensobj = in[i].Nlensobj; 261 out[i].Nstarpar = in[i].Nstarpar; 260 262 out[i].Nextend = in[i].Nextend; 261 263 … … 264 266 out[i].lensingOffset = in[i].lensingOffset; 265 267 out[i].lensobjOffset = in[i].lensobjOffset; 268 out[i].starparOffset = in[i].starparOffset; 266 269 out[i].extendOffset = in[i].extendOffset; 267 out[i].paramsOffset = in[i].paramsOffset;268 270 269 271 out[i].refColorBlue = in[i].refColorBlue; … … 663 665 } 664 666 667 StarPar *StarPar_PS1_V5_ToInternal (StarPar_PS1_V5 *in, off_t Nvalues) { 668 669 off_t i; 670 StarPar *out; 671 672 ALLOCATE_ZERO (out, StarPar, Nvalues); 673 674 for (i = 0; i < Nvalues; i++) { 675 dvo_starpar_init (&out[i]); 676 677 out[i].R = in[i].R; 678 out[i].D = in[i].D; 679 out[i].galLat = in[i].galLat; 680 out[i].galLon = in[i].galLon; 681 682 out[i].Ebv = in[i].Ebv ; 683 out[i].dEbv = in[i].dEbv ; 684 out[i].DistMag = in[i].DistMag ; 685 out[i].dDistMag = in[i].dDistMag; 686 out[i].M_r = in[i].M_r ; 687 out[i].dM_r = in[i].dM_r ; 688 out[i].FeH = in[i].FeH ; 689 out[i].dFeH = in[i].dFeH ; 690 out[i].uRA = in[i].uRA ; 691 out[i].uDEC = in[i].uDEC ; 692 693 out[i].averef = in[i].averef; 694 out[i].objID = in[i].objID ; 695 out[i].catID = in[i].catID ; 696 } 697 return (out); 698 } 699 700 StarPar_PS1_V5 *StarParInternalTo_PS1_V5 (StarPar *in, off_t Nvalues) { 701 702 off_t i; 703 StarPar_PS1_V5 *out; 704 705 ALLOCATE_ZERO (out, StarPar_PS1_V5, Nvalues); 706 707 for (i = 0; i < Nvalues; i++) { 708 709 out[i].R = in[i].R; 710 out[i].D = in[i].D; 711 out[i].galLat = in[i].galLat; 712 out[i].galLon = in[i].galLon; 713 714 out[i].Ebv = in[i].Ebv ; 715 out[i].dEbv = in[i].dEbv ; 716 out[i].DistMag = in[i].DistMag ; 717 out[i].dDistMag = in[i].dDistMag; 718 out[i].M_r = in[i].M_r ; 719 out[i].dM_r = in[i].dM_r ; 720 out[i].FeH = in[i].FeH ; 721 out[i].dFeH = in[i].dFeH ; 722 out[i].uRA = in[i].uRA ; 723 out[i].uDEC = in[i].uDEC ; 724 725 out[i].averef = in[i].averef; 726 out[i].objID = in[i].objID ; 727 out[i].catID = in[i].catID ; 728 } 729 return (out); 730 } 731 665 732 # define RAW_IMAGE_NAME_LEN 117 666 733 … … 676 743 677 744 for (i = 0; i < Nvalues; i++) { 678 memcpy (&out[i].coords, &in[i].coords, sizeof(Coords)); 745 // this is only safe because the initial 120 bytes in Coords match CoordsDisk 746 memcpy (&out[i].coords, &in[i].coords, sizeof(CoordsDisk)); 747 out[i].coords.mosaic = NULL; 748 out[i].coords.offsetMap = NULL; 679 749 680 750 // RAW_IMAGE_NAME_LEN == DVO_IMAGE_NAME_LEN … … 741 811 742 812 for (i = 0; i < Nvalues; i++) { 743 memcpy (&out[i].coords, &in[i].coords, sizeof(Coords)); 813 // this is only save because the initial 120 bytes in Coords match CoordsDisk 814 memcpy (&out[i].coords, &in[i].coords, sizeof(CoordsDisk)); 744 815 745 816 // RAW_IMAGE_NAME_LEN == DVO_IMAGE_NAME_LEN … … 920 991 out[i].lensingOffset = in[i].lensingOffset; 921 992 out[i].lensobjOffset = in[i].lensobjOffset; 993 out[i].starparOffset = in[i].starparOffset; 922 994 out[i].extendOffset = in[i].extendOffset; 923 out[i].paramsOffset = in[i].paramsOffset;924 995 925 996 out[i].refColorBlue = in[i].refColorBlue; … … 1194 1265 1195 1266 1267 Lensing *Lensing_PS1_V5_ALT_ToInternal (Lensing_PS1_V5_ALT *in, off_t Nvalues) { 1268 1269 off_t i; 1270 Lensing *out; 1271 1272 ALLOCATE_ZERO (out, Lensing, Nvalues); 1273 1274 for (i = 0; i < Nvalues; i++) { 1275 dvo_lensing_init (&out[i]); 1276 1277 out[i].X11_sm_obj = in[i].X11_sm_obj; 1278 out[i].X12_sm_obj = in[i].X12_sm_obj; 1279 out[i].X22_sm_obj = in[i].X22_sm_obj; 1280 out[i].E1_sm_obj = in[i].E1_sm_obj; 1281 out[i].E2_sm_obj = in[i].E2_sm_obj; 1282 1283 out[i].X11_sh_obj = in[i].X11_sh_obj; 1284 out[i].X12_sh_obj = in[i].X12_sh_obj; 1285 out[i].X22_sh_obj = in[i].X22_sh_obj; 1286 out[i].E1_sh_obj = in[i].E1_sh_obj; 1287 out[i].E2_sh_obj = in[i].E2_sh_obj; 1288 1289 out[i].X11_sm_psf = in[i].X11_sm_psf; 1290 out[i].X12_sm_psf = in[i].X12_sm_psf; 1291 out[i].X22_sm_psf = in[i].X22_sm_psf; 1292 out[i].E1_sm_psf = in[i].E1_sm_psf; 1293 out[i].E2_sm_psf = in[i].E2_sm_psf; 1294 1295 out[i].X11_sh_psf = in[i].X11_sh_psf; 1296 out[i].X12_sh_psf = in[i].X12_sh_psf; 1297 out[i].X22_sh_psf = in[i].X22_sh_psf; 1298 out[i].E1_sh_psf = in[i].E1_sh_psf; 1299 out[i].E2_sh_psf = in[i].E2_sh_psf; 1300 1301 out[i].F_ApR5 = in[i].F_ApR5; 1302 out[i].dF_ApR5 = in[i].dF_ApR5; 1303 out[i].sF_ApR5 = in[i].sF_ApR5; 1304 out[i].fF_ApR5 = in[i].fF_ApR5; 1305 1306 out[i].F_ApR6 = in[i].F_ApR6; 1307 out[i].dF_ApR6 = in[i].dF_ApR6; 1308 out[i].sF_ApR6 = in[i].sF_ApR6; 1309 out[i].fF_ApR6 = in[i].fF_ApR6; 1310 1311 out[i].detID = in[i].detID; 1312 out[i].objID = in[i].objID; 1313 out[i].catID = in[i].catID; 1314 1315 out[i].averef = in[i].averef; 1316 } 1317 return (out); 1318 } 1319 -
trunk/Ohana/src/libdvo/src/dvo_convert_elixir.c
r37035 r37807 210 210 211 211 for (i = 0; i < Nvalues; i++) { 212 memcpy (&out[i].coords, &in[i].coords, sizeof(Coords)); 212 // this is only safe because the initial 120 bytes in Coords match CoordsDisk 213 memcpy (&out[i].coords, &in[i].coords, sizeof(CoordsDisk)); 214 out[i].coords.mosaic = NULL; 215 out[i].coords.offsetMap = NULL; 213 216 214 217 // RAW_IMAGE_NAME_LEN < DVO_IMAGE_NAME_LEN … … 280 283 281 284 for (i = 0; i < Nvalues; i++) { 282 memcpy (&out[i].coords, &in[i].coords, sizeof(Coords)); 285 // this is only safe because the initial 120 bytes in Coords match CoordsDisk 286 memcpy (&out[i].coords, &in[i].coords, sizeof(CoordsDisk)); 283 287 284 288 // RAW_IMAGE_NAME_LEN < DVO_IMAGE_NAME_LEN -
trunk/Ohana/src/libdvo/src/dvo_convert_loneos.c
r37035 r37807 188 188 189 189 for (i = 0; i < Nvalues; i++) { 190 memcpy (&out[i].coords, &in[i].coords, sizeof(Coords)); 190 // this is only safe because the initial 120 bytes in Coords match CoordsDisk 191 memcpy (&out[i].coords, &in[i].coords, sizeof(CoordsDisk)); 192 out[i].coords.mosaic = NULL; 193 out[i].coords.offsetMap = NULL; 191 194 192 195 // RAW_IMAGE_NAME_LEN < DVO_IMAGE_NAME_LEN … … 259 262 260 263 for (i = 0; i < Nvalues; i++) { 261 memcpy (&out[i].coords, &in[i].coords, sizeof(Coords)); 264 // this is only safe because the initial 120 bytes in Coords match CoordsDisk 265 memcpy (&out[i].coords, &in[i].coords, sizeof(CoordsDisk)); 262 266 263 267 // RAW_IMAGE_NAME_LEN < DVO_IMAGE_NAME_LEN -
trunk/Ohana/src/libdvo/src/dvo_convert_panstarrs_DEV_0.c
r37035 r37807 227 227 228 228 for (i = 0; i < Nvalues; i++) { 229 memcpy (&out[i].coords, &in[i].coords, sizeof(Coords)); 229 // this is only safe because the initial 120 bytes in Coords match CoordsDisk 230 memcpy (&out[i].coords, &in[i].coords, sizeof(CoordsDisk)); 231 out[i].coords.mosaic = NULL; 232 out[i].coords.offsetMap = NULL; 230 233 231 234 // RAW_IMAGE_NAME_LEN < DVO_IMAGE_NAME_LEN … … 297 300 298 301 for (i = 0; i < Nvalues; i++) { 299 memcpy (&out[i].coords, &in[i].coords, sizeof(Coords)); 302 // this is only safe because the initial 120 bytes in Coords match CoordsDisk 303 memcpy (&out[i].coords, &in[i].coords, sizeof(CoordsDisk)); 300 304 301 305 // RAW_IMAGE_NAME_LEN < DVO_IMAGE_NAME_LEN -
trunk/Ohana/src/libdvo/src/dvo_convert_panstarrs_DEV_1.c
r37035 r37807 227 227 228 228 for (i = 0; i < Nvalues; i++) { 229 memcpy (&out[i].coords, &in[i].coords, sizeof(Coords)); 229 // this is only safe because the initial 120 bytes in Coords match CoordsDisk 230 memcpy (&out[i].coords, &in[i].coords, sizeof(CoordsDisk)); 231 out[i].coords.mosaic = NULL; 232 out[i].coords.offsetMap = NULL; 230 233 231 234 // RAW_IMAGE_NAME_LEN < DVO_IMAGE_NAME_LEN … … 297 300 298 301 for (i = 0; i < Nvalues; i++) { 299 memcpy (&out[i].coords, &in[i].coords, sizeof(Coords)); 302 // this is only safe because the initial 120 bytes in Coords match CoordsDisk 303 memcpy (&out[i].coords, &in[i].coords, sizeof(CoordsDisk)); 300 304 301 305 // RAW_IMAGE_NAME_LEN < DVO_IMAGE_NAME_LEN -
trunk/Ohana/src/libdvo/src/dvo_image.c
r37035 r37807 200 200 201 201 gfits_create_matrix (&db[0].header, &db[0].matrix); 202 gfits_table_set_Image (&db[0].ftable , NULL, 0);202 gfits_table_set_Image (&db[0].ftable); 203 203 204 204 gfits_modify (&db[0].header, "NIMAGES", "%d", 1, 0); … … 207 207 dvo_image_createID (&db[0].header); 208 208 209 if (db[0].format == DVO_FORMAT_INTERNAL) gfits_modify (&db[0].header, "FORMAT", "%s", 1, "INTERNAL");209 // if (db[0].format == DVO_FORMAT_INTERNAL) gfits_modify (&db[0].header, "FORMAT", "%s", 1, "INTERNAL"); 210 210 if (db[0].format == DVO_FORMAT_LONEOS) gfits_modify (&db[0].header, "FORMAT", "%s", 1, "LONEOS"); 211 211 if (db[0].format == DVO_FORMAT_ELIXIR) gfits_modify (&db[0].header, "FORMAT", "%s", 1, "ELIXIR"); … … 221 221 if (db[0].format == DVO_FORMAT_PS1_V5) gfits_modify (&db[0].header, "FORMAT", "%s", 1, "PS1_V5"); 222 222 if (db[0].format == DVO_FORMAT_PS1_REF) gfits_modify (&db[0].header, "FORMAT", "%s", 1, "PS1_REF"); 223 if (db[0].format == DVO_FORMAT_PS1_SIM) gfits_modify (&db[0].header, "FORMAT", "%s", 1, "PS1_SIM"); 223 224 224 225 return; … … 267 268 } 268 269 270 int gfits_table_set_Image (FTable *ftable) { 271 272 Header *header; 273 274 header = ftable[0].header; 275 276 gfits_table_mkheader_Image (header); 277 278 /* create table */ 279 if (!gfits_create_table (header, ftable)) return (FALSE); 280 281 return (TRUE); 282 } 283 284 int gfits_table_mkheader_Image (Header *header) { 285 286 /* create table header */ 287 if (!gfits_create_table_header (header, "BINTABLE", "DVO_IMAGE")) return (FALSE); 288 289 /* define table layout */ 290 /** TABLE DEFINITION **/ 291 gfits_define_bintable_column (header, "D", "CRVAL1", "coordinate at reference pixel", "", 1.0, 0.0); 292 gfits_define_bintable_column (header, "D", "CRVAL2", "coordinate at reference pixel", "", 1.0, 0.0); 293 gfits_define_bintable_column (header, "E", "CRPIX1", "coordinate of reference pixel", "", 1.0, 0.0); 294 gfits_define_bintable_column (header, "E", "CRPIX2", "coordinate of reference pixel", "", 1.0, 0.0); 295 gfits_define_bintable_column (header, "E", "CDELT1", "degrees per pixel", "", 1.0, 0.0); 296 gfits_define_bintable_column (header, "E", "CDELT2", "degrees per pixel", "", 1.0, 0.0); 297 gfits_define_bintable_column (header, "E", "PC1_1", "rotation matrix", "", 1.0, 0.0); 298 gfits_define_bintable_column (header, "E", "PC1_2", "rotation matrix", "", 1.0, 0.0); 299 gfits_define_bintable_column (header, "E", "PC2_1", "rotation matrix", "", 1.0, 0.0); 300 gfits_define_bintable_column (header, "E", "PC2_2", "rotation matrix", "", 1.0, 0.0); 301 gfits_define_bintable_column (header, "14E", "POLYTERMS", "higher order warping terms", "", 1.0, 0.0); 302 if (sizeof(void *) == 4) { 303 gfits_define_bintable_column (header, "J", "POINTER1", "", "", 1.0, 0.0); 304 gfits_define_bintable_column (header, "J", "POINTER2", "", "", 1.0, 0.0); 305 } 306 if (sizeof(void *) == 8) { 307 gfits_define_bintable_column (header, "K", "POINTER1", "", "", 1.0, 0.0); 308 gfits_define_bintable_column (header, "K", "POINTER2", "", "", 1.0, 0.0); 309 } 310 gfits_define_bintable_column (header, "15A", "CTYPE", "coordinate type", "", 1.0, 0.0); 311 gfits_define_bintable_column (header, "A", "NPOLYTERMS", "order of polynomial", "", 1.0, 0.0); 312 gfits_define_bintable_column (header, "J", "TZERO", "readout time (row 0)", "", 1.0, 0.0); 313 gfits_define_bintable_column (header, "J", "NSTAR", "number of stars on image", "", 1.0, 0.0); 314 gfits_define_bintable_column (header, "E", "SECZ", "airmass", "mag", 1.0, 0.0); 315 gfits_define_bintable_column (header, "I", "NX", "image width", "", 1.0, 0.0); 316 gfits_define_bintable_column (header, "I", "NY", "image height", "", 1.0, 0.0); 317 gfits_define_bintable_column (header, "E", "APMIFIT", "aperture correction", "mag", 1.0, 0.0); 318 gfits_define_bintable_column (header, "E", "DAPMIFIT", "apmifit error", "mag", 1.0, 0.0); 319 gfits_define_bintable_column (header, "E", "MCAL", "calibration mag", "mag", 1.0, 0.0); 320 gfits_define_bintable_column (header, "E", "DMCAL", "error on Mcal", "mag", 1.0, 0.0); 321 gfits_define_bintable_column (header, "I", "XM", "image chisq", "10*log(value)", 1.0, 0.0); 322 gfits_define_bintable_column (header, "I", "PHOTCODE", "identifier for CCD,", "", 1.0, 0.0); 323 gfits_define_bintable_column (header, "E", "EXPTIME", "exposure time", "seconds", 1.0, 0.0); 324 gfits_define_bintable_column (header, "E", "ST", "sidereal time of exposure", "", 1.0, 0.0); 325 gfits_define_bintable_column (header, "E", "LAT", "observatory latitude", "degrees", 1.0, 0.0); 326 gfits_define_bintable_column (header, "E", "RA_CENTER", "image center", "degrees", 1.0, 0.0); 327 gfits_define_bintable_column (header, "E", "DEC_CENTER", "image center", "degrees", 1.0, 0.0); 328 gfits_define_bintable_column (header, "E", "RADIUS", "image radius", "degrees", 1.0, 0.0); 329 gfits_define_bintable_column (header, "E", "REF_COLOR_BLUE", "median astrometry ref color", "", 1.0, 0.0); 330 gfits_define_bintable_column (header, "E", "REF_COLOR_RED", "median astrometry ref color", "", 1.0, 0.0); 331 gfits_define_bintable_column (header, "117A", "NAME", "name of original image ", "", 1.0, 0.0); 332 gfits_define_bintable_column (header, "B", "DETECTION_LIMIT", "detection limit", "10*mag", 1.0, 0.0); 333 gfits_define_bintable_column (header, "B", "SATURATION_LIMIT", "saturation limit", "10*mag", 1.0, 0.0); 334 gfits_define_bintable_column (header, "B", "CERROR", "astrometric error", "50*arcsec", 1.0, 0.0); 335 gfits_define_bintable_column (header, "B", "FWHM_X", "PSF x width", "25*arcsec", 1.0, 0.0); 336 gfits_define_bintable_column (header, "B", "FWHM_Y", "PSF y width", "25*arcsec", 1.0, 0.0); 337 gfits_define_bintable_column (header, "B", "TRATE", "scan rate", "100 usec/pixel", 1.0, 0.0); 338 gfits_define_bintable_column (header, "B", "CCDNUM", "CCD ID number", "", 1.0, 0.0); 339 gfits_define_bintable_column (header, "J", "FLAGS", "image quality flags", "", 1.0, 0.0); 340 gfits_define_bintable_column (header, "J", "IMAGE_ID", "internal image ID", "", 1.0, 0.0); 341 gfits_define_bintable_column (header, "J", "PARENT_ID", "associated ref image", "", 1.0, 0.0); 342 gfits_define_bintable_column (header, "J", "EXTERN_ID", "external image ID", "", 1.0, 0.0); 343 gfits_define_bintable_column (header, "I", "SOURCE_ID", "analysis source ID", "", 1.0, 0.0); 344 gfits_define_bintable_column (header, "I", "NLINK_ASTROM", "mean number of matched measurements for astrometry", "", 1.0, 0.0); 345 gfits_define_bintable_column (header, "I", "NLINK_PHOTOM", "mean number of matched measurements for astrometry", "", 1.0, 0.0); 346 gfits_define_bintable_column (header, "I", "UBERCAL_DIST", "distance to nearest ubercal image", "", 1.0, 0.0); 347 gfits_define_bintable_column (header, "E", "XPIX_SYS_ERR", "systematic astrometry error in X", "", 1.0, 0.0); 348 gfits_define_bintable_column (header, "E", "YPIX_SYS_ERR", "systematic astrometry error in Y", "", 1.0, 0.0); 349 gfits_define_bintable_column (header, "E", "MAG_SYS_ERR", "systematic photometry error", "", 1.0, 0.0); 350 gfits_define_bintable_column (header, "I", "N_FIT_ASTROM", "number of stars used for astrometry cal", "", 1.0, 0.0); 351 gfits_define_bintable_column (header, "I", "N_FIT_PHOTOM", "number of stars used for photometry cal", "", 1.0, 0.0); 352 gfits_define_bintable_column (header, "J", "PHOTOM_MAP_ID", "reference to 2D zero point map", "", 1.0, 0.0); 353 gfits_define_bintable_column (header, "J", "ASTROM_MAP_ID", "reference to 2D astrometry map", "", 1.0, 0.0); 354 if (sizeof(void *) == 4) { 355 gfits_define_bintable_column (header, "J", "POINTER3", "", "", 1.0, 0.0); 356 } 357 if (sizeof(void *) == 8) { 358 gfits_define_bintable_column (header, "K", "POINTER3", "", "", 1.0, 0.0); 359 } 360 361 return (TRUE); 362 } 363 364 /* return internal structure representation */ 365 Image *gfits_table_get_Image (FTable *ftable, off_t *Ndata, char *swapped) { 366 367 int Ncols; 368 Image *data; 369 370 Ncols = ftable[0].header[0].Naxis[0]; 371 if (Ncols != sizeof(Image)) { 372 fprintf (stderr, "ERROR: mis-match in table size: width is %d but should be %d bytes\n", Ncols, (int) sizeof(Image)); 373 return NULL; 374 } 375 376 *Ndata = ftable[0].header[0].Naxis[1]; 377 data = (Image *) ftable[0].buffer; 378 379 if (!swapped) { 380 myAbort ("invalid to call this without suppying 'swapped'"); 381 } 382 if (*swapped == FALSE) { 383 myAbort ("invalid for table to be swapped"); 384 } 385 386 return (data); 387 } 388 -
trunk/Ohana/src/libdvo/src/dvo_image_raw.c
r37035 r37807 61 61 if (db[0].format == DVO_FORMAT_PS1_V5) ImageSize = sizeof(Image_PS1_V5); 62 62 if (db[0].format == DVO_FORMAT_PS1_REF) ImageSize = sizeof(Image_PS1_REF); 63 if (db[0].format == DVO_FORMAT_PS1_SIM) ImageSize = sizeof(Image_PS1_SIM); 63 64 64 65 /* check that filesize makes sense */ … … 92 93 if (db[0].format == DVO_FORMAT_PS1_V5) gfits_table_mkheader_Image_PS1_V5 (&db[0].theader); 93 94 if (db[0].format == DVO_FORMAT_PS1_REF) gfits_table_mkheader_Image_PS1_REF (&db[0].theader); 95 if (db[0].format == DVO_FORMAT_PS1_SIM) gfits_table_mkheader_Image_PS1_SIM (&db[0].theader); 94 96 95 97 /* read data from file */ -
trunk/Ohana/src/libdvo/src/dvo_photcode_ops.c
r37116 r37807 1788 1788 m2 = (Ns2 == -1) ? average[0].M : secfilt[Ns2].M; 1789 1789 */ 1790 1791 /*** lensing *********************************************************************************/ 1792 1793 # define LENSFIELD(NAME) \ 1794 float LensValue_##NAME (PhotCode *code, Lensobj *lensobj) { \ 1795 if (code == NULL) return NAN; \ 1796 int Ns = photcodes->hashNsec[code->code]; \ 1797 float value = (Ns == -1) ? NAN : lensobj[Ns].NAME; \ 1798 return (value); \ 1799 } 1800 1801 LENSFIELD(X11_sm_obj); 1802 LENSFIELD(X12_sm_obj); 1803 LENSFIELD(X22_sm_obj); 1804 LENSFIELD(E1_sm_obj); 1805 LENSFIELD(E2_sm_obj); 1806 1807 LENSFIELD(X11_sh_obj); 1808 LENSFIELD(X12_sh_obj); 1809 LENSFIELD(X22_sh_obj); 1810 LENSFIELD(E1_sh_obj); 1811 LENSFIELD(E2_sh_obj); 1812 1813 LENSFIELD(X11_sm_psf); 1814 LENSFIELD(X12_sm_psf); 1815 LENSFIELD(X22_sm_psf); 1816 LENSFIELD(E1_sm_psf); 1817 LENSFIELD(E2_sm_psf); 1818 1819 LENSFIELD(X11_sh_psf); 1820 LENSFIELD(X12_sh_psf); 1821 LENSFIELD(X22_sh_psf); 1822 LENSFIELD(E1_sh_psf); 1823 LENSFIELD(E2_sh_psf); -
trunk/Ohana/src/libdvo/src/dvo_tiny_values.c
r37035 r37807 20 20 measureT[0].dM = measure[0].dM; 21 21 measureT[0].airmass = measure[0].airmass; 22 measureT[0].RoffGAL = measure[0].RoffGAL; 23 measureT[0].DoffGAL = measure[0].DoffGAL; 22 24 measureT[0].Xccd = measure[0].Xccd; 23 25 measureT[0].Yccd = measure[0].Yccd; -
trunk/Ohana/src/libdvo/src/dvo_util.c
r33030 r37807 145 145 if ((image->externID == externID) && (image->sourceID == sourceID)) { 146 146 BuildChipMatch(dvoConfig->images, dvoConfig->nImages); 147 if (FindMosaicForImage(dvoConfig->images, dvoConfig->nImages, i)) { 148 return image; 149 } else { 150 fprintf(stderr, "FindMosaicForImage failed\n"); 151 return NULL; 152 } 147 return image; 153 148 } 154 149 } -
trunk/Ohana/src/libdvo/src/flatcorr_io.c
r33963 r37807 183 183 } 184 184 185 // eddie uses cell_x = (int) (X + X_PAD) / (base + X_PAD) 186 // where base = 600, X_PAD = 8, Y_PAD = 10. denominator is thus (608,610), whic is (4880/8),(4864/8) 187 // these match Eddie's NCELL_X,Y / CHIP_DX,DY, so I think we are good with this: 188 189 # define X_PAD 8 190 # define Y_PAD 10 191 185 192 float FlatCorrectionOffset (FlatCorrectionTable *flatcorr, int ID, int X, int Y) { 186 193 … … 191 198 192 199 // convert X,Y to Xbin, Ybin: 193 int Xbin = MAX(MIN( X* flatcorr->image[seq].Nx / flatcorr->image[seq].DX, flatcorr->image[seq].Nx - 1), 0);194 int Ybin = MAX(MIN( Y* flatcorr->image[seq].Ny / flatcorr->image[seq].DY, flatcorr->image[seq].Ny - 1), 0);200 int Xbin = MAX(MIN((X + X_PAD) * flatcorr->image[seq].Nx / flatcorr->image[seq].DX, flatcorr->image[seq].Nx - 1), 0); 201 int Ybin = MAX(MIN((Y + Y_PAD) * flatcorr->image[seq].Ny / flatcorr->image[seq].DY, flatcorr->image[seq].Ny - 1), 0); 195 202 196 203 // XXX warn if X,Y are out of range? not super important unless *way* out of range -
trunk/Ohana/src/libdvo/src/mosaic_astrom.c
r29938 r37807 1 1 # include <dvo.h> 2 3 // the block of code below was used to define the chip->mosaic relationship before this 4 // was assigned to the coords value 2 5 3 6 off_t getDISentry (e_time start, e_time stop, e_time *startMos, off_t *indexMos, off_t Nmosaic); 4 7 void SortDISindex (e_time *S, off_t *I, off_t N); 8 9 # if (0) 5 10 6 11 /* chip-match table: j = ChipMatch[i], images[j] is DIS for images[i] WRP */ … … 93 98 } 94 99 95 int BuildChipMatch_old (Image *images, off_t Nimages) { 100 // this is a very old version of BuildChipMatch which does not use bisection 101 int BuildChipMatch_nosort (Image *images, off_t Nimages) { 96 102 97 103 off_t i, j, NDIS; … … 140 146 } 141 147 142 int BuildChipMatch (Image *images, off_t Nimages) { 148 // this is an old version of BuildChipMatch which stores the results here in a local static variable 149 int BuildChipMatch_static (Image *images, off_t Nimages) { 143 150 144 151 off_t i, j, NDIS; … … 198 205 return (TRUE); 199 206 } 200 207 # endif 208 209 // XXX Note that this links (images[i].coords.mosaic, images[i].parent) will break 210 // if we reallocate the Image array in the middle of program 211 int BuildChipMatch (Image *images, off_t Nimages) { 212 213 off_t i, j, NDIS; 214 215 off_t Ndis = 0; 216 off_t *DISentry = NULL; 217 e_time *DIStzero = NULL; 218 219 if (DISentry != NULL) free (DISentry); 220 if (DIStzero != NULL) free (DIStzero); 221 222 // allocate containers for DIS indexing 223 Ndis = 0; 224 NDIS = 100; 225 ALLOCATE (DISentry, off_t, NDIS); 226 ALLOCATE (DIStzero, e_time, NDIS); 227 228 // find all DIS images, save tzero (& photcode?) 229 for (i = 0; i < Nimages; i++) { 230 if (strcmp(&images[i].coords.ctype[4], "-DIS")) continue; 231 DISentry[Ndis] = i; 232 DIStzero[Ndis] = images[i].tzero; 233 Ndis ++; 234 if (Ndis >= NDIS) { 235 NDIS += 100; 236 REALLOCATE (DISentry, off_t, NDIS); 237 REALLOCATE (DIStzero, e_time, NDIS); 238 } 239 } 240 241 // sort the index, start, and stop by the start times: 242 SortDISindex (DIStzero, DISentry, Ndis); 243 244 /* find all matched WRP images */ 245 for (i = 0; i < Nimages; i++) { 246 images[i].parent = NULL; // reset to NULL 247 images[i].coords.mosaic = NULL; // reset to NULL 248 if (strcmp(&images[i].coords.ctype[4], "-WRP")) continue; // only define link for WRP coords 249 250 j = getDISentry (images[i].tzero, images[i].tzero + (int) images[i].exptime, DIStzero, DISentry, Ndis); 251 if (j == -1) { 252 fprintf (stderr, "WARNING: can't find matching mosaic \n"); 253 continue; 254 } 255 if (j >= Nimages) myAbort("invalid DIS entry"); 256 images[i].parent = &images[j]; 257 images[i].coords.mosaic = &images[j].coords; 258 } 259 return (TRUE); 260 } 261 262 // use bisection to find the overlapping mosaic 201 263 off_t getDISentry (e_time start, e_time stop, e_time *startMos, off_t *indexMos, off_t Nmosaic) { 202 203 // use bisection to find the overlapping mosaic204 264 205 265 off_t Nlo, Nhi, N; -
trunk/Ohana/src/libdvo/src/skyregion_gsc.c
r34088 r37807 204 204 for (i = 0; i < Nregions; i++) { 205 205 strncpy (temp, &buffer[i*48], 48); 206 temp[4 9] = 0;206 temp[48] = 0; 207 207 hstgsc_hms_to_deg (&Rmin, &Rmax, &Dmin, &Dmax, &temp[7]); 208 208 if (Dmax < Dmin) SWAP (Dmin, Dmax); -
trunk/Ohana/src/libdvo/src/skyregion_ops.c
r35102 r37807 16 16 if (c) return (c+1); 17 17 return name; 18 } 19 20 /* find region which corresponds to the given index */ 21 SkyList *SkyRegionByIndex (SkyTable *table, int index) { 22 23 SkyList *list; 24 25 ALLOCATE (list, SkyList, 1); 26 ALLOCATE (list[0].regions, SkyRegion *, 1); 27 ALLOCATE (list[0].filename, char *, 1); 28 list[0].Nregions = 0; 29 list[0].ownElements = FALSE; // this list is only holding a view to the elements 30 strcpy (list[0].hosts, table[0].hosts); 31 32 list[0].regions[0] = &table[0].regions[index]; 33 list[0].filename[0] = table[0].filename[index]; 34 list[0].Nregions = 1; 35 return (list); 18 36 } 19 37 … … 250 268 } 251 269 252 if( Rmax > (Rmin+180.)) {253 254 double temp = Rmax;255 Rmax = Rmin;256 Rmin = temp;257 }258 259 270 list = SkyListByBounds (table, depth, Rmin, Rmax, Dmin, Dmax); 260 return (list); 261 } 262 271 272 // fprintf (stderr, "%s : %f - %f, %f - %f : %d\n", 273 // image->name, Rmin, Rmax, Dmin, Dmax, (int) list->Nregions); 274 275 return (list); 276 } 277 278 // a region like -10 10 0 20 will become 350 10 0 20 and return all regions on both sides of 0,360 263 279 SkyList *SkyListByBounds (SkyTable *table, int depth, double Rmin, double Rmax, double Dmin, double Dmax) { 264 280
Note:
See TracChangeset
for help on using the changeset viewer.
