## data structures in DVO

DVO uses several data structures, defined in `loneos.h` to represent data in the database tables. This document attempts to describe the actual usage, some of which may disagree with the comment entries in `loneos.h`. Image

name | type | value | units
--- | --- | --- | ---
coords | Coords | astrometry |
tzero | unsigned int | readout time row 0 | unix time
nstar | unsigned int | number of stars on image |
secz | short int | airmass | 1000*airmass
NX | short int | image size | pixels
NY | short int | image size | pixels
apmifit | short int | aperture correction | 1000*mag
dapmifit | short int | error | 1000*mag
source | short int | photcode |
Mcal | short int | relphot correciton | 1000*mag
dMcal | short int | error | 1000*mag
Xm | short int | image chi-square | 100*log(chisq)
name[32] | char | image name |
detection_limit | unsigned char |  | 10*mag
saturation_limit | unsigned char |  | 10*mag
cerror | unsigned char | astrometric error | 50*arcsec
fwhm_x | unsigned char | average FWHM X | 25*arcsec
fwhm_y | unsigned char | average FWHM Y | 25*arcsec
trate | unsigned char | drift rate | 10000*sec/pix
exptime | float | exposure time | seconds
code | char | data flags |
ccdnum | unsigned char | mosaic CCD ID number |
dummy[20] | char | extra |
order | short int | order of Mcal function |
Mx | short int | Mcal polynomial term |
My | short int | Mcal polynomial term |
Mxx | short int | Mcal polynomial term |
Mxy | short int | Mcal polynomial term |
Myy | short int | Mcal polynomial term |
Mxxx | short int | Mcal polynomial term |
Mxxy | short int | Mcal polynomial term |
Mxyy | short int | Mcal polynomial term |
Myyy | short int | Mcal polynomial term |
Mxxxx | short int | Mcal polynomial term |
Mxxxy | short int | Mcal polynomial term |
Mxxyy | short int | Mcal polynomial term |
Mxyyy | short int | Mcal polynomial term |
Myyyy | short int | Mcal polynomial term |

apmifit, dapmifit are needed for dophot data, but not sextractor data. are these correctly handled? skyprobe used Mxxxx for Ncal and Myyyy for sky - can this be reconciled?

### codes in Image

- ID_IMAGE_NOCAL = 0x04 - internal to relphot
- ID_IMAGE_POOR = 0x02 - set by relphot
- ID_IMAGE_SKIP = 0x04 - use by relphot (!!!)

Average

name | type | value | units
--- | --- | --- | ---
R | float | RA | decimal degrees J2000
D | float | DEC | decimal degrees J2000
M | short int |  | 1000*mag
Nm | unsigned short | N measure |
Nn | unsigned short | N missing |
Xp | short int | position scatter | 100*arcsec
Xm | short int | mag chisq | 100*log(chisq)
code | unsigned short | data flags |
offset | signed int | measure offset |
missing | signed int | missing offset |
dM | short int | error on M | 1000*log(value)
Xg | short int | best chisq value | ??

### codes in Average

- set to 0 by addstar, etc
- ID_STAR_NOCAL = 0x0001 - set by relphot
- ID_PROPER = 0x0400 - set by addusno, used by markrock
- ID_BAD_DATE = 0x0800 - deprecate (not currently set)
- ID_TRANSIENT = 0x1000 - not currently set?
- ID_VARIABLE = 0x2000 - not currently set?
- ID_ROCK = 0xa000 - set by markrock
- ID_GHOST = 0xc001 - set by fixcat, markstar
- ID_TRAIL = 0xc002 - set by fixcat, markstar
- ID_BLEED = 0xc003 - set by fixcat, markstar, markrock
- ID_COSMIC = 0xc004 - set by markrock Measure

  name | type | value | units
  --- | --- | --- | ---
  dR | short int | RA offset | 100*arcsec
  dD | short int | DEC offset | 100*arcsec
  M | short int | catalog mag | 1000*mag
  Mcal | short int | image cal mag | 1000*mag
  Mgal | short int | 'galaxy' mag, | 1000*mag
  airmass | short int | (airmass - 1), | 1000*airmass
  FWx | short int | fwhm major axis | 100*arcsec
  dM | unsigned char | mag error | 1000*mag
  fwy | unsigned char | minor/major ratio |
  theta | unsigned char | angle wrt ccd X dir | degree*(256/360)
  dophot | char | dophot type |
  source | unsigned short | photcode |
  t | unsigned int | time | unix time
  averef | unsigned int | average entry |
  dt | short int | exposure time | 2500*log(exptime)
  flags | unsigned short | data flags |

  ### flags in Measure

  - ID_MEAS_POOR = 0x0001 - set by relphot, unset?
  - ID_MEAS_NOCAL = 0x0002 - set by relphot, unset?
  - BLEND_IMAGE = 0x0100 - set by addstar, etc
  - BLEND_CATALOG = 0x0200 - set by addstar, etc
  - BLEND_IMAGE_NEIGHBOR = 0x1000 - set by addstar, etc
  - PART_OF_TRAIL = 0x2000 - set by markstar, fixcat, used by markrock
  - GHOST_DATA = 0x4000 - set by markstar, fixcat, used by markrock
  relphot flag meanings: ID_IMAGE_NOCAL : completely ignore image (internal only) ID_IMAGE_SKIP : externally marked, don't include in Mrel, calculate Mcal (?) ID_IMAGE_POOR : internally marked, don't include in Mrel, calculate Mcal (?) ID_STAR_NOCAL : poor star, don't include in Mcal, calculate Mrel STAR_BAD == (average.Xm > STAR_CHISQ) || (average.dM > STAR_SCATTER) || (NVALID < MEAS_TOOFEW) ID_MEAS_NOCAL : skip this measurement (temporary, internal) ID_MEAS_POOR : poor star, don't include in Mcal, calculate Mrel MEAS_POOR == (3 sigma outlier) || (out of detector area) currently NOT sticky!! -- uniphot.h: # define MEAS_POOR 0x0001 # define MEAS_NOCAL 0x0002 # define ID_IMAGE_SKIP 0x0004 relphot.h: # define ID_VARIABLE 0x2000 # define ID_TRANSIENT 0x1000 /* is this mutually exclusive with USNO? */ # define ID_BAD_DATA 0x0800 /* stationary object with some bad data points */ # define ID_PROPER 0x0400 /* star with large proper motion */ # define MEAS_POOR 0x0001 # define MEAS_NOCAL 0x0002 # define ID_IMAGE_SKIP 0x0004 things to update, cleanup finish fix of photcode in imregister-3.0, etc move flag constants from relphot/uniphot/photdbc include -> loneos.h watch for use of Xp, Xg, code in photdbc & status.extract, status.gstar status.extract.NVALID : count !(measure.flag & MEAS_POOR) fix error with ID_IMAGE_NOCAL == ID_IMAGE_SKIP make sure ID_IMAGE_POOR is saved and ID_IMAGE_SKIP is kept, including with -mosaic should STAR_BAD be saved or not? probably not: there is not one per photcode MEAS_POOR should be saved, MEAS_NOCAL should not recompile all dvo programs, test photdbc check on the use of flags, etc; consistent with relphot, uniphot?