# include "markrock.h"

double PhotRel (Measure *measure, PhotCodeData *photcodes, double ZP) {

  int Np;
  double Mrel, Klam;

  Np = photcodes[0].hashcode[measure[0].source];

  if (photcodes[0].code[Np].type == PHOT_REF) {
    Mrel = 0.001 * measure[0].M;
    return (Mrel);
  }

  Klam = photcodes[0].code[Np].K;
  
  Mrel = 0.001*(measure[0].M + Klam*(measure[0].airmass - 1000) + photcodes[0].code[Np].C - measure[0].Mcal) - ZP;
	  
  return (Mrel);

}

double PhotInst (Measure *measure, PhotCodeData *photcodes, double ZP) {

  int Np;
  double M, Klam;

  Np = photcodes[0].hashcode[measure[0].source];

  if (photcodes[0].code[Np].type == PHOT_REF) {
    M = 0.001 * measure[0].M;
    return (M);
  }

  M = 0.001*(measure[0].M - measure[0].dt);
	  
  return (M);

}

double PhotAbs (Measure *measure, PhotCodeData *photcodes, double ZP) {

  int Np;
  double Mabs, Klam;

  Np = photcodes[0].hashcode[measure[0].source];

  if (photcodes[0].code[Np].type == PHOT_REF) {
    Mabs = 0.001 * measure[0].M;
    return (Mabs);
  }

  Klam = photcodes[0].code[Np].K;
  
  /* Mabs = 0.001*(measure[0].M + Klam*(measure[0].airmass - 1000) + photcodes[0].code[Np].C) - ZP; */

  Mabs = 0.001*(measure[0].M + Klam*(measure[0].airmass - 1000) + photcodes[0].code[Np].C) - ZP;
  
  return (Mabs);
	  
}
