IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 40267


Ignore:
Timestamp:
Dec 12, 2017, 7:38:42 AM (9 years ago)
Author:
eugene
Message:

fix PSO / PSX names

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ohana.20170822/src/dvopsps/src/insert_objects_dvopsps_catalog.c

    r40212 r40267  
    11# include "dvopsps.h"
    22# define DEBUG 0
     3
     4int Format_PSX_Name (char *buffer, int Nbuffer, double tmp_ra, double tmp_dec);
    35
    46int insert_objects_dvopsps_catalog (Catalog *catalog, char *basename, MYSQL *mysql) {
     
    267269  double Tmean = average->Tmean == 0 ? NAN : ohana_sec_to_mjd (average->Tmean);
    268270
    269 // XXX this bit could/should be autocoded...
     271  char coord_buffer[128];
     272
     273  // XXX this bit could/should be autocoded...
    270274  PrintIOBuffer (ave_buffer, " (");
    271275  PrintIOBuffer (ave_buffer, OFF_T_FMT", ", average->extID);         
     
    288292  PRINT_FLOAT(ave_buffer, average->dD,       "%.5f, ");  // 0.010 mas precision
    289293
    290   // Add names.
    291   int ra_hr,ra_min,ra_sec,ra_fracsec;
    292   int dec_deg,dec_min,dec_sec,dec_fracsec;
    293   double tmp_ra,tmp_dec;
    294 
    295   if ((secfilt->NstackDet != 0)&&(isfinite(average->Rstk))&&(isfinite(average->Dstk))) {
    296     tmp_ra = average->Rstk;
    297     tmp_dec = average->Dstk;
    298   }
    299   else {
    300     tmp_ra = average->R;
    301     tmp_dec = average->D;
    302   }
    303  
    304   double dec_sign = (tmp_dec == 0.0) ? 0.0 : tmp_dec / fabs(tmp_dec);
    305   tmp_dec = fabs(tmp_dec);
    306 
    307 
    308   tmp_ra /= 15.0;
    309   ra_hr   = (int) floor(tmp_ra);
    310 
    311   tmp_ra -= ra_hr;
    312   tmp_ra *= 60.0;
    313   ra_min  = (int) floor(tmp_ra);
    314  
    315   tmp_ra -= ra_min;
    316   tmp_ra *= 60.0;
    317   ra_sec  = (int) floor(tmp_ra);
    318 
    319   tmp_ra -= ra_sec;
    320   tmp_ra *= 1000.0;
    321   ra_fracsec = (int) floor(tmp_ra);
    322 
    323   dec_deg = (int) floor(tmp_dec);
    324 
    325   tmp_dec -= dec_deg;
    326   tmp_dec *= 60.0;
    327   dec_min = (int) floor(tmp_dec);
    328 
    329   tmp_dec -= dec_min;
    330   tmp_dec *= 60.0;
    331   dec_sec = (int) floor(tmp_dec);
    332 
    333   tmp_dec -= dec_sec;
    334   tmp_dec *= 1000.0;
    335   dec_fracsec = (int) floor(tmp_dec);
    336 
    337   dec_deg *= (int) dec_sign;
    338 
    339   // IAU NAME
    340   PrintIOBuffer(ave_buffer, "'PSO J%02d%02d%02d.%03d%+03d%02d%02d.%03d',  ",
    341                 ra_hr,ra_min,ra_sec,ra_fracsec,
    342                 dec_deg,dec_min,dec_sec,dec_fracsec);
    343 
    344   // PSO NAME
    345   if ((secfilt->NstackDet != 0)&&(isfinite(average->Rstk))&&(isfinite(average->Dstk))) {
    346     tmp_ra = average->Rstk;
    347     tmp_dec = average->Dstk;
    348   }
    349   else {
    350     tmp_ra = average->R;
    351     tmp_dec = average->D;
    352   }
    353 
    354   PrintIOBuffer(ave_buffer, "'PSO J%09.5f%+09.5f',  ",
    355                 tmp_ra,tmp_dec);
     294  int useStack = (secfilt->NstackDet != 0) && isfinite(average->Rstk) && isfinite(average->Dstk);
     295
     296  double tmp_ra  = useStack ? average->Rstk : average->R;
     297  double tmp_dec = useStack ? average->Dstk : average->D;
     298
     299  // PSX NAME
     300  Format_PSX_Name (coord_buffer, 128, tmp_ra, tmp_dec);
     301  PrintIOBuffer(ave_buffer, "'%s',  ", coord_buffer);
     302
     303  // PSO NAME (IAU approved)
     304  PrintIOBuffer(ave_buffer, "'PSO J%09.5f%+09.5f',  ", tmp_ra,tmp_dec);
    356305
    357306  // End names
     
    524473  return TRUE;
    525474}
     475
     476// XXX if the coords have NAN values (not sure why that would happen), return FALSE?
     477int Format_PSX_Name (char *buffer, int Nbuffer, double tmp_ra, double tmp_dec) {
     478
     479  // Add names.
     480  int ra_hr, ra_min, dec_deg, dec_min;
     481  float ra_sec, dec_sec;
     482
     483  // convert to hours:
     484  tmp_ra /= 15.0;
     485  ra_hr   = (int) floor(tmp_ra);
     486
     487  tmp_ra -= ra_hr;
     488  tmp_ra *= 60.0;
     489  ra_min  = (int) floor(tmp_ra);
     490 
     491  tmp_ra -= ra_min;
     492  tmp_ra *= 60.0;
     493  ra_sec  = tmp_ra;
     494
     495  int dec_sign = (tmp_dec >= 0.0) ? +1 : -1;
     496  tmp_dec = fabs(tmp_dec);
     497
     498  dec_deg = (int) floor(tmp_dec);
     499
     500  tmp_dec -= dec_deg;
     501  tmp_dec *= 60.0;
     502  dec_min = (int) floor(tmp_dec);
     503
     504  tmp_dec -= dec_min;
     505  tmp_dec *= 60.0;
     506  dec_sec = tmp_dec;
     507
     508  // IAU NAME
     509  if (dec_sign == +1) {
     510    snprintf (buffer, Nbuffer, "PSO J%02d %02d %06.3f + %03d %02d %06.3f", ra_hr, ra_min, ra_sec, dec_deg, dec_min, dec_sec);
     511  } else {
     512    snprintf (buffer, Nbuffer, "PSO J%02d %02d %06.3f - %03d %02d %06.3f", ra_hr, ra_min, ra_sec, dec_deg, dec_min, dec_sec);
     513  }
     514  return TRUE;
     515}
Note: See TracChangeset for help on using the changeset viewer.