# include <dvo.h>

/* convert panstarrs-format averages to internal averages */
Average *AveragePMtestToInternal (AveragePMtest *in, int Nvalues) {

  int i;
  Average *out;

  ALLOCATE (out, Average, Nvalues);

  for (i = 0; i < Nvalues; i++) {
    out[i].R       = in[i].R;      
    out[i].D       = in[i].D;      
    out[i].dR      = in[i].dR;      
    out[i].dD      = in[i].dD;      

    out[i].uR      = in[i].uR;      
    out[i].uD      = in[i].uD;      
    out[i].duR     = in[i].duR;      
    out[i].duD     = in[i].duD;      
    out[i].P       = in[i].P;      
    out[i].dP      = in[i].dP;      

    out[i].M       = in[i].M;      
    out[i].dM      = in[i].dM;
    out[i].Xp      = in[i].Xp;     
    out[i].Xm      = in[i].Xm;     
    out[i].Xg      = in[i].Xg;
    out[i].Nm      = in[i].Nm;     
    out[i].Nn      = in[i].Nn;     
    out[i].code    = in[i].code;   
    out[i].offset  = in[i].offset; 
    out[i].missing = in[i].missing;
  }
  return (out);
}

/* convert internal averages to panstarrs-format averages */
AveragePMtest *AverageInternalToPMtest (Average *in, int Nvalues) {

  int i;
  AveragePMtest *out;

  ALLOCATE (out, AveragePMtest, Nvalues);

  for (i = 0; i < Nvalues; i++) {
    out[i].R       = in[i].R;      
    out[i].D       = in[i].D;      
    out[i].dR      = in[i].dR;      
    out[i].dD      = in[i].dD;      

    out[i].uR      = in[i].uR;      
    out[i].uD      = in[i].uD;      
    out[i].duR     = in[i].duR;      
    out[i].duD     = in[i].duD;      
    out[i].P       = in[i].P;      
    out[i].dP      = in[i].dP;      

    out[i].M       = in[i].M;      
    out[i].dM      = in[i].dM;
    out[i].Xp      = in[i].Xp;     
    out[i].Xm      = in[i].Xm;     
    out[i].Xg      = in[i].Xg;
    out[i].Nm      = in[i].Nm;     
    out[i].Nn      = in[i].Nn;     
    out[i].code    = in[i].code;   
    out[i].offset  = in[i].offset; 
    out[i].missing = in[i].missing;
  }
  return (out);
}

