IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 7, 2021, 4:14:19 PM (5 years ago)
Author:
eugene
Message:

major work to revise the grid correction : do not use astrometry to define grid, just subdivide each photcode

Location:
trunk/Ohana/src/relphot
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/relphot

  • trunk/Ohana/src/relphot/include/relphot.h

    r41557 r41647  
    55# include <pthread.h>
    66
    7 /* # define GRID_V1 */
    8 # define GRID_V2
    9 # define NO_IMAGE -100
    10 
    117# define ID_SECF_STACK_PRIMARY 0x00004000
    128
    139# define NBOOTSTRAP 100
     10
     11// MEAS_BAD is used in ImageOps.c, MosaicOps.c, TGroupOps.c to skip specific measurements.
     12// ID_MEAS_AREA is raised for measurements outside the user-specified region of the chips
     13// ID_MEAS_NOCAL is raised for measurements outside the valid time range or for inactive photcodes
     14// Note: these bits are only raised on the temporary MeasureTiny elements and are not saved
     15// to the database files.
     16# define MEAS_BAD (ID_MEAS_AREA | ID_MEAS_NOCAL)
    1417
    1518# ifndef MAX_INT
     
    5356
    5457typedef enum {
    55     MODE_NONE   = 0,
    56     MODE_LOAD   = 1,
    57     MODE_UPDATE = 2,
     58    MODE_NONE           = 0,
     59    MODE_LOAD           = 1,
     60    MODE_UPDATE         = 2,
    5861    MODE_UPDATE_OBJECTS = 3,
    59     MODE_SYNTH_PHOT = 4,
     62    MODE_SYNTH_PHOT     = 4,
    6063} ModeType;
    6164
     
    7073  PS1_w = 6,
    7174} PS1filters;
     75
     76typedef enum {
     77  GRID_MEAN = 0,
     78  GRID_STDEV = 1,
     79  GRID_NPTS = 2,
     80} GridOutputMode;
    7281
    7382typedef struct {
     
    99108  char skipCal;               // if TRUE, this mosaic is incomplete and should not be calibrated
    100109  char inTGroup;
    101   Coords coords;
     110  Coords coords;              // this is only used to set the mosaic center for assign_images used by region hosts
    102111} Mosaic;
    103112
     
    140149  int      nCode;
    141150} TGTimes;
     151
     152typedef struct {
     153  unsigned short photcode;
     154  float **Mgrid; // grid of average corrections
     155  float **dMgrid; // grid of stdev of corrections
     156    int **nMgrid; // grid of number of stars for corrections
     157  int Nx; // bin = int(Xchip * (Nx / NxChip))
     158  int Ny; // bin = int(Ychip * (Ny / NyChip))
     159  float dX; // bin = int(Xchip * dX), dX = Nx / NxChip
     160  float dY; // bin = int(Ychip * dY), dY = Ny / NyChip
     161  // NxChip, NyChip = 4900,4900 for now
     162} GridCorrectionType;
    142163
    143164typedef enum {
     
    366387int    SKY_DEPTH;  /** XXX EAM : depth of catalog tables, fix usage */
    367388char  *SYNTH_ZERO_POINTS;
     389char  *GRID_MEANFILE;
    368390
    369391// globals for parallel region operations
     
    389411double IMAGE_OFFSET;
    390412double NIGHT_SCATTER;
    391 double NIGHT_OFFSET;
     413double NIGHT_CHISQ;
     414double MOSAIC_SCATTER;
     415double MOSAIC_CHISQ;
    392416double STAR_SCATTER;
    393417double STAR_CHISQ;
     
    413437int    MOSAIC_ZEROPT;
    414438int    TGROUP_ZEROPT;
     439int    GRID_ZEROPT;
     440
     441int    GRID_BIN_HSC;
     442int    GRID_BIN_CFH;
     443int    GRID_BIN_GPC1;
     444int    GRID_BIN_GPC2;
    415445
    416446int    FREEZE_IMAGES;
     
    424454int    MANUAL_ITERATION;
    425455int    NLOOP;
    426 int    NGRID;
    427456int    RESET;
    428457int    RESET_ZEROPTS;
     458int    RESET_FLATCORR;
    429459int    REPAIR_WARPS;
    430460int    PRESERVE_PS1;
     461int    REQUIRE_PSFFIT;
    431462int    UPDATE;
    432463int    SAVE_IMAGE_UPDATES;
     
    436467char   MOSAICNAME[256];
    437468char   STATMODE[32];
    438 int    STAR_BAD;
    439 int    MEAS_BAD;
    440469int    STAR_TOOFEW;
    441470int    GRID_TOOFEW;
    442471int    IMAGE_TOOFEW;
    443472double IMAGE_GOOD_FRACTION;
    444 int    IMAGE_BAD;
    445473int    CALIBRATE_STACKS_AND_WARPS;
    446 int    USE_GRID;
     474
    447475int    KEEP_UBERCAL;
    448476char  *OUTROOT;
     
    457485char  *PhotcodeList;
    458486
    459 int    RELPHOT_GRID_X;
    460 int    RELPHOT_GRID_Y;
    461 int    RELPHOT_GRID_BINNING;
    462 
    463487int      *photseclist;
    464488int      Nphotcodes;
     
    490514char *UserCatalog;
    491515
     516enum {GRID_ZPT_MODE_NONE, GRID_ZPT_MODE_ALL, };
     517int GRID_ZPT_MODE;
     518
    492519enum {TGROUP_ZPT_MODE_NONE, TGROUP_ZPT_MODE_GOOD_NIGHT, TGROUP_ZPT_MODE_ALL, };
    493520int TGROUP_ZPT_MODE;
     
    504531
    505532RelphotStages STAGES;
    506 
    507 # ifdef GRID_V1
    508 int setGridMeasure (off_t meas, int cat, double X, double Y);
    509 # endif
    510 
    511 # ifdef GRID_V2
    512 int setGridMeasure (off_t meas, int cat, double X, double Y, int ccdnum);
    513 # endif
    514533
    515534/*** relphot prototypes ***/
     
    523542int           bcatalog            PROTO((Catalog *subcatalog, Catalog *catalog, int Ncat));
    524543void          clean_images        PROTO((void));
    525 void          clean_measures      PROTO((Catalog *catalog, int Ncatalog, int final, FlatCorrectionTable *flatcorr));
     544void          clean_measures      PROTO((Catalog *catalog, int Ncatalog, int final));
    526545void          clean_mosaics       PROTO((void));
    527546void          clean_tgroups       PROTO((void));
     
    549568int SetSignals (void);
    550569
    551 void          freeGridBins        PROTO((int Ncatalog));
     570void          freeGridBins        PROTO((void));
    552571void          freeImageBins       PROTO((int Ncatalog, int doImageList));
    553572void          freeMosaicBins      PROTO((int Ncatalog, int doMosaicList));
     
    560579
    561580float         getMcal             PROTO((off_t meas, int cat, dvoMagClassType class));
    562 float         getMflat            PROTO((off_t meas, int cat, FlatCorrectionTable *flatcorr, Catalog *catalog));
    563 float         getMgrid            PROTO((off_t meas, int cat));
     581float         getMflat            PROTO((off_t meas, int cat, Catalog *catalog));
     582float         getMgridTiny        PROTO((MeasureTiny *measure));
     583float         getMgrid            PROTO((Measure *measure));
    564584float         getMmos             PROTO((off_t meas, int cat));
    565585float         getMgrp             PROTO((off_t meas, int cat, float airmass, float *dZpt));
     
    570590Image        *getimages           PROTO((off_t *N, off_t **LineNumber));
    571591ImageSubset  *getimages_subset    PROTO((off_t *N));
    572 void          global_stats        PROTO((Catalog *catalog, int Ncatalog, FlatCorrectionTable *flatcorr, int nloop));
    573 void          initGrid            PROTO((int dX, int dY));
    574 void          initGridBins        PROTO((Catalog *catalog, int Ncatalog));
     592void          global_stats        PROTO((Catalog *catalog, int Ncatalog, int nloop));
     593void          initGrid            PROTO((void));
     594void          setMflatFromGrid    PROTO((Catalog *catalog));
     595void          initGridBins        PROTO((void));
     596GridCorrectionType *getGridCorrByCode PROTO((int code));
     597GridCorrectionType *getGridCorrNext   PROTO((int *Nlast));
     598int           GridCorrectionSave  PROTO((void));
     599int           GridCorrectionSaveFile  PROTO((char *filename, GridOutputMode mode));
     600void          GridCorrectionLoad  PROTO((char *filename));
    575601void          initImageBins       PROTO((Catalog *catalog, int Ncatalog, int doImageList));
    576602void          initImagesSubset    PROTO((ImageSubset *input, off_t *line_number, off_t N));
    577603void          initImages          PROTO((Image *input, off_t *LineNumber, off_t N));
    578604void          initMosaicBins      PROTO((Catalog *catalog, int Ncatalog, int doMosaicList));
    579 void          initMosaicGrid      PROTO((Image *image, off_t Nimage));
     605void          initMosaicMcal      PROTO((Image *image, off_t Nimage));
    580606void          initMosaics         PROTO((Image *subset, off_t Nsubset, Image *image, char *inSubset, off_t Nimage));
    581607void          initTGroups         PROTO((Image *subset, off_t Nsubset));
     
    621647void          plot_chisq          PROTO((Catalog *catalog, int Ncatalog));
    622648void          plot_defaults       PROTO((Graphdata *graphdata));
    623 void          plot_grid           PROTO((Catalog *catalog, FlatCorrectionTable *flatcorr));
    624649void          plot_images         PROTO((void));
    625650void          plot_list           PROTO((Graphdata *graphdata, double *xlist, double *ylist, int N, char *label, char *format, ...) OHANA_FORMAT(printf, 6, 7) );
    626651void          plot_mosaic_fields  PROTO((Catalog *catalog));
    627652void          plot_mosaics        PROTO((void));
    628 void          plot_scatter        PROTO((Catalog *catalog, int Ncatalog, FlatCorrectionTable *flatcorr));
     653void          plot_scatter        PROTO((Catalog *catalog, int Ncatalog));
    629654void          plot_star_coords    PROTO((Catalog *catalog, int Ncatalog));
    630655void          plot_stars          PROTO((Catalog *catalog, int Ncatalog));
     
    635660int           open_graph          PROTO((int N));
    636661
    637 void          reload_catalogs     PROTO((SkyList *skylist, FlatCorrectionTable *flatcorr, int hostID, char *hostpath));
     662void          reload_catalogs     PROTO((SkyList *skylist, int hostID, char *hostpath));
    638663int           reload_catalogs_parallel PROTO((SkyList *sky));
    639664int           reload_images       PROTO((FITS_DB *db));
    640665int           setExclusions       PROTO((Catalog *catalog, int Ncatalog, int verbose));
    641 void          setMgrid            PROTO((Catalog *catalog, FlatCorrectionTable *flatcorr));
     666void          setMgrid            PROTO((Catalog *catalog, int Ncatalog));
     667void          resetMgrid          PROTO((void));
     668
    642669void          setMcalFromMosaics  PROTO((void));
    643670void          setMcalFromTGroups  PROTO((void));
    644 int           setMcalOutput       PROTO((Catalog *catalog, int Ncatalog, FlatCorrectionTable *flatcorr));
    645 
    646 void          setMcal             PROTO((Catalog *catalog, FlatCorrectionTable *flatcorr));
    647 int           setMmos             PROTO((Catalog *catalog, FlatCorrectionTable *flatcorr));
    648 int           setMgrp             PROTO((Catalog *catalog, FlatCorrectionTable *flatcorr));
    649 
    650 int           setMrel             PROTO((Catalog *catalog, int Ncatalog, FlatCorrectionTable *flatcorr));
    651 void          setMrelFinal        PROTO((Catalog *catalog, FlatCorrectionTable *flatcorr, int simpleAverage));
    652 int           setMrelOutput       PROTO((Catalog *catalog, int Ncatalog, FlatCorrectionTable *flatcorr));
    653 
    654 void          setMcalTest         PROTO((Catalog *catalog, FlatCorrectionTable *flatcorr));
     671int           setMcalOutput       PROTO((Catalog *catalog, int Ncatalog));
     672
     673void          setMcal             PROTO((Catalog *catalog));
     674int           setMmos             PROTO((Catalog *catalog));
     675int           setMgrp             PROTO((Catalog *catalog));
     676
     677int           setMrel             PROTO((Catalog *catalog, int Ncatalog));
     678void          setMrelFinal        PROTO((Catalog *catalog, int simpleAverage));
     679int           setMrelOutput       PROTO((Catalog *catalog, int Ncatalog));
     680
     681void          setMcalTest         PROTO((Catalog *catalog));
    655682
    656683int           setMave             PROTO((Catalog *catalog, int Ncatalog));
    657684void          set_ZP              PROTO((double ZERO));
    658685int           setrefcode          PROTO((Image *image, off_t Nimage));
    659 void          skip_measurements   PROTO((Catalog *catalog, int pass, FlatCorrectionTable *flatcorr));
     686void          skip_measurements   PROTO((Catalog *catalog, int pass));
    660687void          sortA               PROTO((double *X, int N));
    661688void          sortB               PROTO((double *X, double *Y, int N));
     
    663690void          sortD               PROTO((double *X, double *Y, double *Z, int N));
    664691StatType      statsImageM         PROTO((Catalog *catalog));
    665 StatType      statsImageN         PROTO((Catalog *catalog, FlatCorrectionTable *flatcorr));
     692StatType      statsImageN         PROTO((Catalog *catalog));
    666693StatType      statsImageX         PROTO((Catalog *catalog));
    667694StatType      statsImagedM        PROTO((Catalog *catalog));
    668695StatType      statsMosaicM        PROTO((Catalog *catalog));
    669 StatType      statsMosaicN        PROTO((Catalog *catalog, FlatCorrectionTable *flatcorr));
     696StatType      statsMosaicN        PROTO((Catalog *catalog));
    670697StatType      statsMosaicX        PROTO((Catalog *catalog));
    671698StatType      statsMosaicdM       PROTO((Catalog *catalog));
     
    674701StatType      statsTGroupdM       PROTO((Catalog *catalog));
    675702
    676 StatType      statsStarN          PROTO((Catalog *catalog, int Ncatalog, int Nsec, int seccode, FlatCorrectionTable *flatcorr));
     703StatType      statsStarN          PROTO((Catalog *catalog, int Ncatalog, int Nsec, int seccode));
    677704StatType      statsStarS          PROTO((Catalog *catalog, int Ncatalog, int Nsec));
    678705StatType      statsStarX          PROTO((Catalog *catalog, int Ncatalog, int Nsec));
     
    720747
    721748int print_measure_set_alt (Average *average, SecFilt *secfilt, Measure *measure);
    722 int setMrel_catalog_alt (Catalog *catalog, int Nc, int isSetMrelFinal, FlatCorrectionTable *flatcorr, SetMrelInfo *results, int Nsecfilt);
    723 int setMrelAverageExposure (Catalog *catalog, int cat, off_t ave, int Nsecfilt, int isSetMrelFinal, FlatCorrectionTable *flatcorr, SetMrelInfo *results);
    724 int setMrelAverageStack (Catalog *catalog, int cat, off_t ave, int Nsecfilt, FlatCorrectionTable *flatcorr);
    725 int setMrelAverageForcedWarp (Catalog *catalog, int cat, off_t ave, int Nsecfilt, FlatCorrectionTable *flatcorr, SetMrelInfo *results);
     749
     750// in setMrelCatalog.c:
     751int setMrelCatalog (Catalog *catalog, int Nc, int isSetMrelFinal, SetMrelInfo *results, int Nsecfilt);
     752int setMrelAverageExposure (Catalog *catalog, int cat, off_t ave, int Nsecfilt, int isSetMrelFinal, SetMrelInfo *results);
     753int setMrelAverageStack (Catalog *catalog, int cat, off_t ave, int Nsecfilt);
     754int setMrelAverageForcedWarp (Catalog *catalog, int cat, off_t ave, int Nsecfilt, SetMrelInfo *results);
    726755
    727756int setGlobalObjStats (Average *average, Measure *measure);
     
    735764StatDataSet *StatDataSetAlloc (int Nsecfilt, int Nmax);
    736765
    737 int init_synthetic_mags ();
     766int init_synthetic_mags (void);
    738767int add_synthetic_mags (AverageTiny *average, SecFilt *secfilt, MeasureTiny *measure, off_t *Nmeasure, off_t *Nm);
    739768
     
    796825
    797826int SynthZeroPointsLoad (char *filename);
    798 SynthZeroPoints *SynthZeroPointsGet ();
     827SynthZeroPoints *SynthZeroPointsGet (void);
    799828
    800829int relphot_synthphot (SkyList *sky, int hostID, char *hostpath);
     
    815844
    816845void put_astrom_table (AstromOffsetTable *myTable);
    817 void free_astrom_table ();
    818 
    819 int RepairWarpMeasures (Catalog *catalog);
    820 
    821 int FindWarpGroups (void);
    822 int GetWarpSeq (Image *image, int obstime, unsigned short photcode, double Rave, double Dave, float X, float Y);
    823 void FreeWarpGroups (void);
    824 
    825 myIndexType *myIndexInit ();
    826 int myIndexFree (myIndexType *myIndex);
    827 int myIndexUpdateLimits (myIndexType *myIndex, int value);
    828 int myIndexSetRange (myIndexType *myIndex);
    829 int myIndexSetEntry (myIndexType *myIndex, int value, int entry);
    830 int myIndexGetEntry (myIndexType *myIndex, int value);
     846void free_astrom_table (void);
    831847
    832848uint64_t CreatePSPSObjectID(double ra, double dec);
     
    834850uint64_t CreatePSPSDetectionID(double tobs, int ccdid, int detID);
    835851
    836 int MakeStackIndex (void);
    837 void FreeStackGroups (void);
    838 int GetStackSeq (Image *image, double Rstk, double Dstk, unsigned short photcode, float X, float Y);
    839852void sort_by_ra (double *R, double *D, int *I, int *S, int N);
    840 
    841 void RepairWarpMeasuresOpenLogfile ();
    842 void RepairWarpMeasuresCloseLogfile ();
    843853
    844854void dump_tgroups (Catalog *catalog, int Npass);
     
    849859int GetZptIteration (void);
    850860
    851 void SetZeroPointModes (void);
     861void SetZeroPointModes (Catalog *catalog, int Ncatalog);
    852862int UseStandardOLS (ZptFitModeType mode);
    853863int GetActivePhotcodeIndex (int photcode);
     
    857867
    858868int MagResidSave(char *filename, Catalog *catalog);
     869
     870void ResetAverageAndMeasure (Catalog *catalog);
     871void ResetAverageObjects (Catalog *catalog);
     872void ResetImages (Image *subset, off_t Nsubset);
     873void ResetMeasureZeroPoints (MeasureTiny *measure, off_t Nmeasure, off_t Ncat);
     874void ResetAverageActivePhotcodes (SecFilt *secfilt);
     875
     876
Note: See TracChangeset for help on using the changeset viewer.