Auto filename when saving netcdf

Mon, 12 May 2014 12:41:22 +0300

author
Iannis <ulalume3@yahoo.com>
date
Mon, 12 May 2014 12:41:22 +0300
changeset 23
06d612c6cd0a
parent 22
a2355e871b23
child 24
b148076f7295

Auto filename when saving netcdf

generic.py file | annotate | diff | comparison | revisions
--- a/generic.py	Mon May 12 11:14:44 2014 +0300
+++ b/generic.py	Mon May 12 12:41:22 2014 +0300
@@ -186,9 +186,10 @@
                 
             channel.update()
     
-    def save_as_netcdf(self, filename):
+    def save_as_netcdf(self, filename = None):
         """Saves the measurement in the netcdf format as required by the SCC.
-        Input: filename
+        Input: filename. If no filename is provided <measurement_id>.nc will
+               be used. 
         """
         params = self.extra_netcdf_parameters
         needed_parameters = ['Measurement_ID', 'Temperature', 'Pressure']
@@ -198,6 +199,8 @@
             if stored_value is None:
                 raise ValueError('A value needs to be specified for %s' % parameter)
         
+        if not filename:
+            filename = "%s.nc" % self.info['Measurement_ID']
                 
         dimensions = {'points': 1,
                 'channels': 1,

mercurial