Index: trunk/ippToPsps/src/ippToPsps.c
===================================================================
--- trunk/ippToPsps/src/ippToPsps.c	(revision 29316)
+++ trunk/ippToPsps/src/ippToPsps.c	(revision 29317)
@@ -30,5 +30,5 @@
     if (!isfinite(*flux) || *flux < 0.000001) return false;
     if (fluxErr) *fluxErr = fabsf((magnitudeErr * *flux)/1.085736);
-      if (fluxErr)    printf("Mag = %03.03f, Flux = %03.03f, Mag err = %03.03f, Flux Err = %03.03f\n", magnitude, *flux, magnitudeErr, *fluxErr);
+//      if (fluxErr)    printf("Mag = %03.03f, Flux = %03.03f, Mag err = %03.03f, Flux Err = %03.03f\n", magnitude, *flux, magnitudeErr, *fluxErr);
 
     return true;
@@ -162,5 +162,5 @@
 
     psMetadata *arguments = psMetadataAlloc();
-    psMetadataAddStr(arguments, PS_LIST_TAIL, "-expid", 0, "Exposure ID", NULL);
+    psMetadataAddStr(arguments, PS_LIST_TAIL, "-id", 0, "ID", NULL);
     psMetadataAddStr(arguments, PS_LIST_TAIL, "-expname", 0, "Exposure name", NULL);
     psMetadataAddStr(arguments, PS_LIST_TAIL, "-survey", 0, "Survey type", NULL);
@@ -179,6 +179,6 @@
     else {
 
-        char *tmp = psMemIncrRefCounter(psMetadataLookupStr(NULL, arguments, "-expid"));
-        if (tmp) this->expId = atoi(tmp);
+        char *tmp = psMemIncrRefCounter(psMetadataLookupStr(NULL, arguments, "-id"));
+        if (tmp) this->id = atoi(tmp);
         //free(tmp); tmp = NULL;
         this->expName = psMemIncrRefCounter(psMetadataLookupStr(NULL, arguments, "-expname"));
@@ -203,5 +203,5 @@
                 (this->batchType != BATCH_INIT && !this->fitsInPath) || 
                 (this->batchType != BATCH_INIT && !this->resultsPath) || 
-                (this->batchType != BATCH_INIT && this->expId == -1) ||
+                (this->batchType != BATCH_INIT && this->id == -1) ||
                 !this->fitsOutPath || 
                 !this->configsDir || 
@@ -284,7 +284,8 @@
 
     // remaining args
-    this->expId = -1;
+    this->id = -1;
     this->expName = NULL;
     this->surveyType = NULL;
+    this->surveyID = -1;
     this->fitsInPath = NULL;
     this->resultsPath = NULL;
@@ -300,4 +301,9 @@
     this->run = ippToPsps_run;
 
+    // sort out current time
+    time_t now = time(NULL);;
+    struct tm *ts = gmtime(&now); // TODO should be UTC
+    strftime(this->todaysDate, sizeof(this->todaysDate), "%Y-%m-%d", ts);
+
     if (!this->pmconfig) {
 
@@ -333,5 +339,5 @@
     // create filename
     char outputName[100];
-    sprintf(outputName, "%08d.FITS", this->expId);
+    sprintf(outputName, "%08d.FITS", this->id);
     psStringAppend(&this->fitsOutPath, "/%s", outputName);
 
@@ -353,4 +359,12 @@
     }
 
+    // get survey ID using config object
+    if (this->batchType != BATCH_INIT && 
+            !ippToPspsConfig_getSurveyId(this->config, this->surveyType, &this->surveyID)) {
+        
+        this->exitCode = PS_EXIT_CONFIG_ERROR;
+        return this;
+    }
+
     // create XML document for results 
     if (this->resultsPath) {
Index: trunk/ippToPsps/src/ippToPsps.h
===================================================================
--- trunk/ippToPsps/src/ippToPsps.h	(revision 29316)
+++ trunk/ippToPsps/src/ippToPsps.h	(revision 29317)
@@ -22,7 +22,8 @@
 typedef struct {
 
-    uint32_t expId;             // the exposure ID to be used
+    uint32_t id;                 // ID: might be expId for detections, skycell ID etc
     psString expName;           // the exposure name
     psString surveyType;        // the survey type, eg 3PI, MD01, STS, SSS
+    int8_t surveyID;            // survey ID
     uint8_t batchType;          // PSPS batch type
     psString fitsInPath;        // path to FITS input
@@ -37,4 +38,5 @@
     dvoConfig* dvoConfig;       // dvo database
     IppToPspsConfig* config;    // config structure
+    char todaysDate[12];        // today's date
     int exitCode;               // ps exit code
 
