Index: trunk/ippToPsps/scripts/ippToPsps_run.pl
===================================================================
--- trunk/ippToPsps/scripts/ippToPsps_run.pl	(revision 28248)
+++ trunk/ippToPsps/scripts/ippToPsps_run.pl	(revision 28249)
@@ -70,5 +70,5 @@
 
 # make a temporary file for saving results
-my ($resultsFile, $resultsFileName) = tempfile( "/tmp/results.XXXX", UNLINK => !$save_temps);
+my ($resultsFile, $resultsFileName) = tempfile( "/tmp/ippToPsps_results.XXXX", UNLINK => !$save_temps);
 
 process();
@@ -86,5 +86,5 @@
     if ($distGroup =~ m/^MD([0-1][0-9])$/i) {return "MD$1";}
     if ($distGroup =~ m/^M31$/i) {return "M31";}
-    if ($distGroup =~ m/^sts$/i) {return "STS";}
+    if ($distGroup =~ m/^sts$/i) {return "STS1";}
     if ($distGroup =~ m/^SweetSpot$/i) {return "SSS";}
     if ($distGroup =~ m/^(3PI)|(ThreePi)|(SAS)$/i) {return "3PI";}
@@ -140,5 +140,4 @@
             AND chipRun.exp_id = rawExp.exp_id 
             AND camRun.dist_group = '$survey'   
-            AND rawExp.exp_id > 145986 
             GROUP BY  rawExp.exp_id 
             ORDER BY rawExp.exp_id ASC;
@@ -627,5 +626,5 @@
     my $fullJobPath = "$path/$job";
 
-    my ($tempFile, $tempName) = tempfile( "/tmp/dsregList.XXXX", UNLINK => !$save_temps);
+    my ($tempFile, $tempName) = tempfile( "/tmp/ippToPsps_dsregList.XXXX", UNLINK => !$save_temps);
 
     # loop through all batch files in this job directory
@@ -718,5 +717,5 @@
 
         # now write the path to this file out to temp file
-        my ($tempFile, $tempName) = tempfile( "/tmp/inputFileList.XXXX", UNLINK => !$save_temps);
+        my ($tempFile, $tempName) = tempfile( "/tmp/ippToPsps_inputFileList.XXXX", UNLINK => !$save_temps);
         print $tempFile $realFile . "\n";
         close $tempFile;
@@ -794,4 +793,5 @@
     $command .= " -expid $expid";
     $command .= " -expname $expName";
+    $command .= " -survey $surveyType";
     $command .= " -batch $batchType";
     $command .= " -results $resultsFileName";
Index: trunk/ippToPsps/src/ippToPsps.c
===================================================================
--- trunk/ippToPsps/src/ippToPsps.c	(revision 28248)
+++ trunk/ippToPsps/src/ippToPsps.c	(revision 28249)
@@ -93,5 +93,4 @@
     if (this->numOfInputFiles < 1) return false;
 
-
     this->inputFiles = (char**)calloc(this->numOfInputFiles, sizeof(char*));
     for(uint32_t i=0; i<this->numOfInputFiles; i++)
@@ -145,4 +144,5 @@
     psMetadataAddStr(arguments, PS_LIST_TAIL, "-expid", 0, "Exposure ID", NULL);
     psMetadataAddStr(arguments, PS_LIST_TAIL, "-expname", 0, "Exposure name", NULL);
+    psMetadataAddStr(arguments, PS_LIST_TAIL, "-survey", 0, "Survey type", NULL);
     psMetadataAddStr(arguments, PS_LIST_TAIL, "-input", 0, "Path to FITS inout", NULL);
     psMetadataAddStr(arguments, PS_LIST_TAIL, "-output", 0, "Path to FITS output", NULL);
@@ -163,4 +163,5 @@
         //free(tmp); tmp = NULL;
         this->expName = psMemIncrRefCounter(psMetadataLookupStr(NULL, arguments, "-expname"));
+        this->surveyType = psMemIncrRefCounter(psMetadataLookupStr(NULL, arguments, "-survey"));
         this->fitsInPath = psMemIncrRefCounter(psMetadataLookupStr(NULL, arguments, "-input"));
         this->resultsPath = psMemIncrRefCounter(psMetadataLookupStr(NULL, arguments, "-results"));
@@ -179,4 +180,5 @@
         if (
                 (this->batchType != BATCH_INIT && !this->expName) || 
+                (this->batchType != BATCH_INIT && !this->surveyType) || 
                 (this->batchType != BATCH_INIT && !this->fitsInPath) || 
                 (this->batchType != BATCH_INIT && !this->resultsPath) || 
@@ -241,4 +243,5 @@
     this->expId = -1;
     this->expName = NULL;
+    this->surveyType = NULL;
     this->fitsInPath = NULL;
     this->resultsPath = NULL;
Index: trunk/ippToPsps/src/ippToPsps.h
===================================================================
--- trunk/ippToPsps/src/ippToPsps.h	(revision 28248)
+++ trunk/ippToPsps/src/ippToPsps.h	(revision 28249)
@@ -22,4 +22,5 @@
     uint32_t expId;            // the exposure ID to be used
     psString expName;          // the exposure name
+    psString surveyType;       // the survey type, eg 3PI, MD01, STS, SSS
     uint8_t batchType;         // PSPS batch type
     psString fitsInPath;       // path to FITS input
Index: trunk/ippToPsps/src/ippToPspsBatchDetection.c
===================================================================
--- trunk/ippToPsps/src/ippToPspsBatchDetection.c	(revision 28248)
+++ trunk/ippToPsps/src/ippToPspsBatchDetection.c	(revision 28249)
@@ -65,9 +65,10 @@
     fits_write_col(this->fitsOut, TSTRING, FRAMEMETA_FRAMENAME, 1, 1, 1, &this->expName, &status);
 
-    int8_t surveyID = 0; // TODO
+    int8_t surveyID = -1;
+    if (!ippToPspsConfig_getSurveyId(this->config, this->surveyType, &surveyID)) {return PS_EXIT_DATA_ERROR;}
     fits_write_col(this->fitsOut, TBYTE, FRAMEMETA_SURVEYID, 1, 1, 1, &surveyID, &status);
 
     int8_t filterID = -1;
-    ippToPspsConfig_getFilterId(this->config, filterType, &filterID);
+    if (!ippToPspsConfig_getFilterId(this->config, filterType, &filterID)) {return PS_EXIT_DATA_ERROR;}
     fits_write_col(this->fitsOut, TBYTE, FRAMEMETA_FILTERID, 1, 1, 1, &filterID, &status);
 
Index: trunk/ippToPsps/src/ippToPspsConfig.c
===================================================================
--- trunk/ippToPsps/src/ippToPspsConfig.c	(revision 28248)
+++ trunk/ippToPsps/src/ippToPspsConfig.c	(revision 28249)
@@ -325,4 +325,18 @@
 
     return ret;
+}
+
+// gets survey ID from survey name
+bool ippToPspsConfig_getSurveyId(IppToPspsConfig* this, const char* surveyType, int8_t* surveyId) {
+
+    char buffer[10];
+    if (!ippToPspsConfig_getInitValue(this, "Survey", "name", surveyType, "surveyID", buffer)) {
+
+        *surveyId = -1;
+        return false;
+    }
+
+    *surveyId = atoi(buffer);
+    return true;
 }
 
Index: trunk/ippToPsps/src/ippToPspsConfig.h
===================================================================
--- trunk/ippToPsps/src/ippToPspsConfig.h	(revision 28248)
+++ trunk/ippToPsps/src/ippToPspsConfig.h	(revision 28249)
@@ -59,4 +59,5 @@
 // getters
 bool ippToPspsConfig_getFilterId(IppToPspsConfig* this, const char* filterType, int8_t* filterId);
+bool ippToPspsConfig_getSurveyId(IppToPspsConfig* this, const char* surveyType, int8_t* surveyId);
 
 #endif // IPPTOPSPSCONFIG_H
