[cig-commits] r11753 - in cs/portal/trunk/seismo/SeismoWebPortal: . templates/SeismoWebPortal

leif at geodynamics.org leif at geodynamics.org
Fri Apr 4 20:27:54 PDT 2008


Author: leif
Date: 2008-04-04 20:27:54 -0700 (Fri, 04 Apr 2008)
New Revision: 11753

Modified:
   cs/portal/trunk/seismo/SeismoWebPortal/cmt.py
   cs/portal/trunk/seismo/SeismoWebPortal/forms.py
   cs/portal/trunk/seismo/SeismoWebPortal/models.py
   cs/portal/trunk/seismo/SeismoWebPortal/templates/SeismoWebPortal/event_detail.html
   cs/portal/trunk/seismo/SeismoWebPortal/templates/SeismoWebPortal/par_file.txt
   cs/portal/trunk/seismo/SeismoWebPortal/templates/SeismoWebPortal/parameters.pml
   cs/portal/trunk/seismo/SeismoWebPortal/templates/SeismoWebPortal/single_source_event_form.html
   cs/portal/trunk/seismo/SeismoWebPortal/templates/SeismoWebPortal/source_detail.html
   cs/portal/trunk/seismo/SeismoWebPortal/templates/SeismoWebPortal/specfem3dglobeparameters_detail.html
   cs/portal/trunk/seismo/SeismoWebPortal/templates/SeismoWebPortal/specfem3dglobeparameters_form.html
   cs/portal/trunk/seismo/SeismoWebPortal/views.py
Log:
Further normalized the database: Factored-out 'CMTSolution', moved PDE
info from 'Source' to 'Event'.  Removed junk from Specfem parameters.


Modified: cs/portal/trunk/seismo/SeismoWebPortal/cmt.py
===================================================================
--- cs/portal/trunk/seismo/SeismoWebPortal/cmt.py	2008-04-04 14:28:06 UTC (rev 11752)
+++ cs/portal/trunk/seismo/SeismoWebPortal/cmt.py	2008-04-05 03:27:54 UTC (rev 11753)
@@ -34,19 +34,19 @@
 
     def createFromDBModel(cls, model):
         cmtSolution = CMTSolution()
-        cmtSolution.dataSource = model.dataSource.name
-        cmtSolution.year = model.when.year
-        cmtSolution.month = model.when.month
-        cmtSolution.day = model.when.day
-        cmtSolution.hour = model.when.hour
-        cmtSolution.minute = model.when.minute
-        cmtSolution._second = float(model.when.second) + (float(model.microsecond) / 1000000.0)
-        cmtSolution.sourceLatitude = model.sourceLatitude
-        cmtSolution.sourceLongitude = model.sourceLongitude
-        cmtSolution.sourceDepth = model.sourceDepth
-        cmtSolution.sourceMB = model.sourceMB
-        cmtSolution.sourceMs = model.sourceMs
-        cmtSolution.regionName = model.region.name
+        cmtSolution.dataSource = model.event.dataSource.name
+        cmtSolution.year = model.event.when.year
+        cmtSolution.month = model.event.when.month
+        cmtSolution.day = model.event.when.day
+        cmtSolution.hour = model.event.when.hour
+        cmtSolution.minute = model.event.when.minute
+        cmtSolution._second = float(model.event.when.second) + (float(model.event.microsecond) / 1000000.0)
+        cmtSolution.sourceLatitude = model.event.sourceLatitude
+        cmtSolution.sourceLongitude = model.event.sourceLongitude
+        cmtSolution.sourceDepth = model.event.sourceDepth
+        cmtSolution.sourceMB = model.event.sourceMB
+        cmtSolution.sourceMs = model.event.sourceMs
+        cmtSolution.regionName = model.event.region.name
         cmtSolution.eventName = model.eventName
         cmtSolution.timeShift = model.timeShift
         cmtSolution.halfDuration = model.halfDuration

Modified: cs/portal/trunk/seismo/SeismoWebPortal/forms.py
===================================================================
--- cs/portal/trunk/seismo/SeismoWebPortal/forms.py	2008-04-04 14:28:06 UTC (rev 11752)
+++ cs/portal/trunk/seismo/SeismoWebPortal/forms.py	2008-04-05 03:27:54 UTC (rev 11753)
@@ -3,11 +3,11 @@
 from django.contrib.auth import authenticate, login
 from django.contrib.auth.models import User
 from django.core import validators
-from models import Location
+from models import Location, CMTSolution
 from models import Specfem3DGlobeMesh, Event, DataSource, Region, Source
 from models import UserInfo, Invite, Folder
 from models import EventWorkspace, StationList
-from cmt import CMTSolution
+import cmt
 import config
 
 
@@ -280,57 +280,56 @@
 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
 
-class SingleSourceEventAddManipulator(Source.AddManipulator):
+class SingleSourceEventAddManipulator(CMTSolution.AddManipulator):
 
     def __init__(self):
         super(SingleSourceEventAddManipulator, self).__init__()
         # replace generic fields with custom fields
 
-        del self['event']
-        del self['dataSource']
-        del self['region']
-        del self['sourceLocation'] # ignored
         del self['location']
-        self.fields.extend([forms.TextField('dataSource',  maxlength=100,  is_required=True),
-                            forms.TextField('region',      maxlength=100,  is_required=True),
-                            forms.FloatField('sourceLatitude', max_digits=19, decimal_places=10, is_required=True),
-                            forms.FloatField('sourceLongitude', max_digits=19, decimal_places=10, is_required=True),
-                            forms.FloatField('latitude', max_digits=19, decimal_places=10, is_required=True),
+        self.fields.extend([forms.FloatField('latitude', max_digits=19, decimal_places=10, is_required=True),
                             forms.FloatField('longitude', max_digits=19, decimal_places=10, is_required=True),
                             ])
         return
 
     def save(self, new_data, user):
         from datetime import datetime
+
+        # Get/create the location.
+        location = Location.getLocation(new_data['latitude'], new_data['longitude'])
+        del new_data['latitude']
+        del new_data['longitude']
+
+        # Get/create the CMTSolution.
+        kwds = {}
+        for k in new_data.iterkeys():
+            kwds[k] = new_data[k] # convert from MultiValueDict to dict
+        kwds['location'] = location
+        cmtSolution = CMTSolution.getCMTSolution(**kwds)
         
+        # Create the DataSource and Region.
+        dataSource, created = DataSource.objects.get_or_create(name = "ZZZ")
+        region, created = Region.objects.get_or_create(name = "ZZZZ")
+
         # Create the new Event.
-        event = Event.objects.create()
+        event = Event.objects.create(
+            dataSource = dataSource,
+            when = datetime.min,
+            microsecond = 0,
+            sourceLocation = location,
+            sourceDepth = 0.0,
+            sourceMB = 0.0,
+            sourceMs = 0.0,
+            region = region,
+            )
 
-        # Create the DataSource and Region.
-        dataSource, created = DataSource.objects.get_or_create(name = new_data['dataSource'])
-        region, created = Region.objects.get_or_create(name = new_data['region'])
-        
-        # get/create the location
-        sourceLocation = Location.getLocation(new_data['sourceLatitude'], new_data['sourceLongitude'])
-        location = Location.getLocation(new_data['latitude'], new_data['longitude'])
-
         # Add the Source.
-        args = {}
-        for k,v in new_data.items():
-            args[k] = v
-        args['event'] = event
-        args['dataSource'] = dataSource
-        args['region'] = region
-        args['when'] = datetime.combine(args['when_date'], args['when_time'])
-        del args['when_date']
-        del args['when_time']
-        args['sourceLocation'] = sourceLocation
-        del args['sourceLatitude']
-        del args['sourceLongitude']
-        args['location'] = location
-        del args['latitude']
-        del args['longitude']
-        source = Source.objects.create(**args)
+        source = Source.objects.create(
+            event = event,
+            eventName = "000000Z",
+            timeShift = 0.0,
+            cmtSolution = cmtSolution,
+            )
 
         # Create a new workspace for this event.
         workspace = EventWorkspace(event = event,
@@ -338,30 +337,20 @@
                                    )
         workspace.save()
         
-        workspace.fsNode.name = source.eventName
-        workspace.fsNode.save()
-
         return workspace
 
 
-class SingleSourceEventChangeManipulator(Source.ChangeManipulator):
+class SingleSourceEventChangeManipulator(CMTSolution.ChangeManipulator):
 
     def __init__(self, workspace):
         self.workspace = workspace
-        self.event = workspace.event
         
-        object_id = self.event.singleSource.id
+        object_id = workspace.event.singleSource.cmtSolution.id
         super(SingleSourceEventChangeManipulator, self).__init__(object_id)
         
         # replace generic fields with custom fields
-        del self['event']
-        del self['dataSource']
-        del self['region']
-        del self['sourceLocation'] # ignored
         del self['location']
-        self.fields.extend([forms.TextField('dataSource',  maxlength=100,  is_required=True),
-                            forms.TextField('region',      maxlength=100,  is_required=True),
-                            forms.FloatField('latitude', max_digits=19, decimal_places=10, is_required=True),
+        self.fields.extend([forms.FloatField('latitude', max_digits=19, decimal_places=10, is_required=True),
                             forms.FloatField('longitude', max_digits=19, decimal_places=10, is_required=True),
                             ])
         return
@@ -373,28 +362,23 @@
         return new_data
 
     def save(self, new_data, user):
-        from datetime import datetime
-        
-        # Save event info.
-        event = self.event
-        event.save()
 
-        # Create the DataSource and Region.
-        dataSource, created = DataSource.objects.get_or_create(name = new_data['dataSource'])
-        region, created = Region.objects.get_or_create(name = new_data['region'])
+        source = self.workspace.event.singleSource
 
-        # get/create the location
+        # Get/create the location.
         location = Location.getLocation(new_data['latitude'], new_data['longitude'])
+        del new_data['latitude']
+        del new_data['longitude']
 
-        source = event.singleSource
-        source.dataSource = dataSource
-        source.region = region
-        
+        # Get/create the CMTSolution.
+        kwds = {}
+        for k in new_data.iterkeys():
+            kwds[k] = new_data[k] # convert from MultiValueDict to dict
+        kwds['location'] = location
+        source.cmtSolution = CMTSolution.getCMTSolution(**kwds)
+
         # Save the Source.
-        new_data['event'] = event.id
-        new_data['location'] = location.id
-        new_data['sourceLocation'] = source.sourceLocation.id
-        super(SingleSourceEventChangeManipulator, self).save(new_data)
+        source.save()
         
         return self.workspace
 
@@ -413,23 +397,45 @@
         if not errors.get('cmtsolution'):
             try:
                 cmtSolution = new_data['cmtsolution']['content']
-                CMTSolution.parse(cmtSolution)
+                cmt.CMTSolution.parse(cmtSolution)
             except Exception, e:
                 errors['cmtsolution'] = ['Please select a file in CMTSOLUTION format.']
 
         return errors
 
     def save(self, new_data, user):
+        import datetime
 
         # Parse the uploaded CMTSOLUTION file.
         cmtSolution = new_data['cmtsolution']['content']
-        cmtSolutionList = CMTSolution.parse(cmtSolution)
+        cmtSolutionList = cmt.CMTSolution.parse(cmtSolution)
 
         filename = new_data['cmtsolution']['filename']
 
         # Create the new event.
-        event = Event.objects.create(name = filename)
+        cmtSolution = cmtSolutionList[0]
+        
+        when = datetime.datetime(cmtSolution.year,
+                                 cmtSolution.month,
+                                 cmtSolution.day,
+                                 cmtSolution.hour,
+                                 cmtSolution.minute,
+                                 cmtSolution.second)
+        
+        dataSource, created = DataSource.objects.get_or_create(name = cmtSolution.dataSource)
+        region, created = Region.objects.get_or_create(name = cmtSolution.regionName)
 
+        event = Event.objects.create(
+            dataSource        = dataSource,
+            when              = when,
+            microsecond       = cmtSolution.microsecond,
+            sourceLocation    = Location.getLocation(cmtSolution.sourceLatitude, cmtSolution.sourceLongitude),
+            sourceDepth       = cmtSolution.sourceDepth,
+            sourceMB          = cmtSolution.sourceMB,
+            sourceMs          = cmtSolution.sourceMs,
+            region            = region,
+            )
+
         # Add each source.
         for cmtSolution in cmtSolutionList:
             Source.saveSource(event, cmtSolution)

Modified: cs/portal/trunk/seismo/SeismoWebPortal/models.py
===================================================================
--- cs/portal/trunk/seismo/SeismoWebPortal/models.py	2008-04-04 14:28:06 UTC (rev 11752)
+++ cs/portal/trunk/seismo/SeismoWebPortal/models.py	2008-04-05 03:27:54 UTC (rev 11753)
@@ -133,8 +133,20 @@
 
 class Event(models.Model):
 
-    name = models.CharField(maxlength=100)
+    # Preliminary Determination of Epicenter (PDE)
+    # This info isn't actually used by any of the codes.
+    dataSource = models.ForeignKey(DataSource)
+    when = models.DateTimeField()
+    microsecond = models.IntegerField()
+    sourceLocation = models.ForeignKey(Location)
+    sourceDepth = models.FloatField(max_digits=19, decimal_places=10)
+    sourceMB = models.FloatField(max_digits=19, decimal_places=10)
+    sourceMs = models.FloatField(max_digits=19, decimal_places=10)
+    region = models.ForeignKey(Region)
 
+    sourceLatitude = property(lambda self: self.sourceLocation.latitude)
+    sourceLongitude = property(lambda self: self.sourceLocation.longitude)
+
     def _getSingleSource(self):
         if not hasattr(self, '_singleSource'):
             if self.source_set.count() == 1:
@@ -147,8 +159,6 @@
     def sources(self):
         return self.source_set.order_by('timeShift')
 
-    def __str__(self): return self.name
-
     def icon(self):
         ss = self.singleSource
         return ss and ss.beachball() or '<img class="icon" src="%s/icons/document.gif">' % config.root
@@ -158,24 +168,7 @@
         super(Event, self).delete()
 
 
-class Source(models.Model):
-
-    # an event is composed of one or more sources
-    event = models.ForeignKey(Event)
-
-    dataSource = models.ForeignKey(DataSource)
-
-    when = models.DateTimeField()
-    microsecond = models.IntegerField()
-    
-    sourceLocation = models.ForeignKey(Location, related_name='pde_set')
-    sourceDepth = models.FloatField(max_digits=19, decimal_places=10)
-    sourceMB = models.FloatField(max_digits=19, decimal_places=10)
-    sourceMs = models.FloatField(max_digits=19, decimal_places=10)
-    region = models.ForeignKey(Region)
-    
-    eventName = models.CharField(maxlength=100)
-    timeShift = models.FloatField(max_digits=19, decimal_places=10)
+class CMTSolution(models.Model):
     halfDuration = models.FloatField(max_digits=19, decimal_places=10)
     location = models.ForeignKey(Location, db_index=True)
     depth = models.FloatField(max_digits=19, decimal_places=10)
@@ -186,14 +179,47 @@
     Mrp = models.FloatField(max_digits=19, decimal_places=10)
     Mtp = models.FloatField(max_digits=19, decimal_places=10)
 
-    def __str__(self): return self.eventName
+    @classmethod
+    def getCMTSolution(cls,
+                       halfDuration, location, depth,
+                       Mrr, Mtt, Mpp, Mrt, Mrp, Mtp):
+        obj, created = cls.objects.get_or_create(
+            location = location, # db_index
+            halfDuration = halfDuration,
+            depth = depth,
+            Mrr = Mrr,
+            Mtt = Mtt,
+            Mpp = Mpp,
+            Mrt = Mrt,
+            Mrp = Mrp,
+            Mtp = Mtp
+            )
+        return obj
 
-    sourceLatitude = property(lambda self: self.sourceLocation.latitude)
-    sourceLongitude = property(lambda self: self.sourceLocation.longitude)
 
-    latitude = property(lambda self: self.location.latitude)
-    longitude = property(lambda self: self.location.longitude)
+class Source(models.Model):
 
+    # an event is composed of one or more sources
+    event = models.ForeignKey(Event)
+    
+    eventName = models.CharField(maxlength=100)
+    timeShift = models.FloatField(max_digits=19, decimal_places=10)
+    cmtSolution = models.ForeignKey(CMTSolution)
+
+    def __str__(self): return self.eventName
+
+    latitude = property(lambda self: self.cmtSolution.location.latitude)
+    longitude = property(lambda self: self.cmtSolution.location.longitude)
+    halfDuration = property(lambda self: self.cmtSolution.halfDuration)
+    location = property(lambda self: self.cmtSolution.location)
+    depth = property(lambda self: self.cmtSolution.depth)
+    Mrr = property(lambda self: self.cmtSolution.Mrr)
+    Mtt = property(lambda self: self.cmtSolution.Mtt)
+    Mpp = property(lambda self: self.cmtSolution.Mpp)
+    Mrt = property(lambda self: self.cmtSolution.Mrt)
+    Mrp = property(lambda self: self.cmtSolution.Mrp)
+    Mtp = property(lambda self: self.cmtSolution.Mtp)
+
     def _getMrrStr2f(self): return "%.2f" % (self.Mrr * 1.0e-26)
     def _getMttStr2f(self): return "%.2f" % (self.Mtt * 1.0e-26)
     def _getMppStr2f(self): return "%.2f" % (self.Mpp * 1.0e-26)
@@ -221,36 +247,14 @@
         src = "%s/beachballs/%d.gif" % (config.root, self.id)
         return '<img class="icon" src="%s">' % src
 
-    def cmtSolution(self):
+    def cmtSolutionText(self):
         from cmt import CMTSolution
         return str(CMTSolution.createFromDBModel(self))
 
     @classmethod
     def saveSource(cls, event, cmtSolution):
-        import datetime
 
-        when = datetime.datetime(cmtSolution.year,
-                                 cmtSolution.month,
-                                 cmtSolution.day,
-                                 cmtSolution.hour,
-                                 cmtSolution.minute,
-                                 cmtSolution.second)
-        
-        dataSource, created = DataSource.objects.get_or_create(name = cmtSolution.dataSource)
-        region, created = Region.objects.get_or_create(name = cmtSolution.regionName)
-        
-        source = Source(
-            event             = event,
-            dataSource        = dataSource,
-            when              = when,
-            microsecond       = cmtSolution.microsecond,
-            sourceLocation    = Location.getLocation(cmtSolution.sourceLatitude, cmtSolution.sourceLongitude),
-            sourceDepth       = cmtSolution.sourceDepth,
-            sourceMB          = cmtSolution.sourceMB,
-            sourceMs          = cmtSolution.sourceMs,
-            region            = region,
-            eventName         = cmtSolution.eventName,
-            timeShift         = cmtSolution.timeShift,
+        dbCMTSolution = CMTSolution.getCMTSolution(
             halfDuration      = cmtSolution.halfDuration,
             location          = Location.getLocation(cmtSolution.latitude, cmtSolution.longitude),
             depth             = cmtSolution.depth,
@@ -262,6 +266,13 @@
             Mtp               = cmtSolution.Mtp,
             )
         
+        source = Source(
+            event             = event,
+            eventName         = cmtSolution.eventName,
+            timeShift         = cmtSolution.timeShift,
+            cmtSolution       = dbCMTSolution,
+            )
+        
         source.save()
         return
 
@@ -350,11 +361,6 @@
 
 MODEL_TYPES = tuple([(num+1, model_types[num][1]) for num in xrange(0, len(model_types))])
 
-SIMULATION_TYPES = (
-    (1, 'forward'),
-)
-
-
 NCHUNKS_CHOICES = (
     (1, 'regional with 1 chunk'),
     (2, 'regional with 2 chunks'),
@@ -378,8 +384,6 @@
     nex_eta_c = models.IntegerField(core=True, choices=NEX_C_CHOICES, default=2)
     def nex_xi(self): return 8 * self.nex_xi_c * self.nproc_xi
     def nex_eta(self): return 8 * self.nex_eta_c * self.nproc_eta
-    #save_files = models.BooleanField(core=True)
-    def save_files(self): return False
 
     # this is for regional only (when type == 2), and when global, all these values are fixed
     angular_width_eta = models.FloatField(max_digits=19, decimal_places=10, core=True)
@@ -454,47 +458,14 @@
 
 
 
-def isValidRecordLength(field_data, all_data):
-    lower = 0.0
-    upper = 100.0
-    number = float(field_data)
-    if lower < number and number <= upper:
-        return
-    raise validators.ValidationError("Please enter a positive number between %.1f and %.1f." % (lower, upper))
-
-
 class Specfem3DGlobeParameters(models.Model):
-    #
-    # general information about the simulation
-    #
+
     fsNode = models.ForeignKey(FSNode, null=True)
     
     mesh = models.ForeignKey(Specfem3DGlobeMesh, limit_choices_to = userFSChoices)
     model = models.ForeignKey(Specfem3DGlobeModel, limit_choices_to = userFSChoices)
-
-    #
-    # specific information starts here
-    #
     receivers_can_be_buried = models.BooleanField(core=True)
-    print_source_time_function = models.BooleanField(core=True)
-    save_forward = models.BooleanField(core=True, default=False)
 
-    movie_surface = models.BooleanField(core=True)
-    movie_volume = models.BooleanField(core=True)
-
-    # hdur_movie:
-    hdur_movie = models.FloatField(max_digits=19, decimal_places=10, core=True, default=0.0, blank=True)
-    # absorbing_conditions: set to true for regional, and false for global
-    absorbing_conditions = models.BooleanField(core=True)
-    # ntstep_between_frames: typical value is 100 time steps
-    ntstep_between_frames = models.IntegerField(core=True, default=100)
-    # ntstep_between_output_info: typical value is 100 time steps
-    ntstep_between_output_info = models.IntegerField(core=True, default=100, blank=True)
-    # ntstep_between_output_seismos : typical value is 5000
-    ntstep_between_output_seismos = models.IntegerField(core=True, default=5000, blank=True)
-    # simulation_type:
-    simulation_type = models.IntegerField(choices=SIMULATION_TYPES, default=1)
-
     def __str__(self): return self.fsNode.name
     
     def icon(self):
@@ -507,18 +478,16 @@
 
     def auto_absorbing_conditions(self):
         """Return 'True' for regional, 'False' for global."""
-        # The corresponding data field, 'absorbing_conditions', is
-        # currently unused.  Instead, we always turn on absorbing
-        # conditions, except for global simulations (absorbing
-        # conditions are not permitted in the full earth).
-        # Presumably, one might have reason to set it to 'False' for
-        # regional simulations, since it does exist as a separate
-        # input to the code.
+        # Absorbing conditions must be disabled for global simulations
+        # (otherwise the code bombs with an error message).  For
+        # regional simulations, we always turn on absorbing
+        # conditions.  Presumably, one might have reason to set it to
+        # 'False' for regional simulations, since it does exist as a
+        # separate input to the code... but currently the UI does not
+        # allow this.
         return not self.mesh.nchunks == 6
 
     def save(self):
-        self.ntstep_between_output_info = 100
-        self.ntstep_between_output_seismos = 5000
         super(Specfem3DGlobeParameters, self).save()
         if self.fsNode is None:
             self.fsNode = FSNode.newNode(self)
@@ -527,23 +496,6 @@
             self.fsNode.save() # touch
         return
 
-    def run(self):
-        r = Run()
-        r.simulation = self
-        r.save()
-        return r
-
-    def _getStatus(self):
-        if not hasattr(self, '_status'):
-            self._status = "new"
-            for run in self.run_set.all():
-                self._status = run.status
-        return self._status
-    status = property(_getStatus)
-
-    def get_simulation_type_id(self):
-        return {1: 'forward', 2: 'adjoint', 3: 'both'}[self.simulation_type]
-
     class Admin:
         pass
 
@@ -666,6 +618,15 @@
 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
 
+def isValidRecordLength(field_data, all_data):
+    lower = 0.0
+    upper = 100.0
+    number = float(field_data)
+    if lower < number and number <= upper:
+        return
+    raise validators.ValidationError("Please enter a positive number between %.1f and %.1f." % (lower, upper))
+
+
 class EventWorkspace(models.Model):
 
     fsNode = models.ForeignKey(FSNode, null=True)
@@ -765,8 +726,8 @@
 
 class Specfem3DGlobeRequest(models.Model):
     
-    # CMTSOLUTION
     event = models.ForeignKey(Event)
+    stations = models.ForeignKey(StationList)
 
     parameters = models.ForeignKey(Specfem3DGlobeParameters)
     zero_half_duration = models.BooleanField(default=True)
@@ -780,6 +741,7 @@
 class MineosRequest(models.Model):
     
     event = models.ForeignKey(Event)
+    stations = models.ForeignKey(StationList)
 
     parameters = models.ForeignKey(MineosParameters)
     record_length = models.FloatField(max_digits=19, decimal_places=10, core=True, default=20.0,

Modified: cs/portal/trunk/seismo/SeismoWebPortal/templates/SeismoWebPortal/event_detail.html
===================================================================
--- cs/portal/trunk/seismo/SeismoWebPortal/templates/SeismoWebPortal/event_detail.html	2008-04-04 14:28:06 UTC (rev 11752)
+++ cs/portal/trunk/seismo/SeismoWebPortal/templates/SeismoWebPortal/event_detail.html	2008-04-05 03:27:54 UTC (rev 11753)
@@ -12,7 +12,7 @@
 
 <div class=cmtsolution>
     <h3><code>CMTSOLUTION</code></h3>
-    <pre>{{ object.singleSource.cmtSolution }}</pre>
+    <pre>{{ object.singleSource.cmtSolutionText }}</pre>
 </div>
 
 {% else %}

Modified: cs/portal/trunk/seismo/SeismoWebPortal/templates/SeismoWebPortal/par_file.txt
===================================================================
--- cs/portal/trunk/seismo/SeismoWebPortal/templates/SeismoWebPortal/par_file.txt	2008-04-04 14:28:06 UTC (rev 11752)
+++ cs/portal/trunk/seismo/SeismoWebPortal/templates/SeismoWebPortal/par_file.txt	2008-04-05 03:27:54 UTC (rev 11753)
@@ -1,7 +1,7 @@
 
 # forward or adjoint simulation
-SIMULATION_TYPE                 = {{ simulation.simulation_type }}
-SAVE_FORWARD                    = .{{ simulation.save_forward }}.  # save last frame of forward simulation or not
+SIMULATION_TYPE                 = 1
+SAVE_FORWARD                    = .false.  # save last frame of forward simulation or not
 
 # number of chunks (1,2,3 or 6)
 NCHUNKS                         = {{ simulation.mesh.nchunks }}
@@ -48,10 +48,10 @@
 RECORD_LENGTH_IN_MINUTES        = {{ simulation.record_length|stringformat:".1f" }}
 
 # save AVS or OpenDX movies
-MOVIE_SURFACE                   = .{{ simulation.movie_surface }}.
-MOVIE_VOLUME                    = .{{ simulation.movie_volume }}.
-NTSTEP_BETWEEN_FRAMES           = {{ simulation.ntstep_between_frames }}
-HDUR_MOVIE                      = {{ simulation.hdur_movie|stringformat:".1f" }}
+MOVIE_SURFACE                   = .false.
+MOVIE_VOLUME                    = .false.
+NTSTEP_BETWEEN_FRAMES           = 100
+HDUR_MOVIE                      = 0.d0
 
 # save movie in volume.  Will save element if center of element is in prescribed volume
 # top/bottom: depth in KM, use MOVIE_TOP = -100 to make sure the surface is stored.
@@ -72,7 +72,7 @@
 MOVIE_STOP                      = 40000
 
 # save mesh files to check the mesh
-SAVE_MESH_FILES                 = .{{ simulation.mesh.save_files }}.
+SAVE_MESH_FILES                 = .false.
 
 # restart files (number of runs can be 1, 2 or 3, choose 1 for no restart files)
 NUMBER_OF_RUNS                  = 1
@@ -82,10 +82,10 @@
 LOCAL_PATH                      = /scratch/
 
 # interval at which we output time step info and max of norm of displacement
-NTSTEP_BETWEEN_OUTPUT_INFO      = {{ simulation.ntstep_between_output_info }}
+NTSTEP_BETWEEN_OUTPUT_INFO      = 1000
 
 # interval in time steps for temporary writing of seismograms
-NTSTEP_BETWEEN_OUTPUT_SEISMOS   = {{ simulation.ntstep_between_output_seismos }}
+NTSTEP_BETWEEN_OUTPUT_SEISMOS   = 5000000
 NTSTEP_BETWEEN_READ_ADJSRC      = 1000
 
 # output format for the seismograms (one can use either or all of the three formats)
@@ -108,5 +108,5 @@
 RECEIVERS_CAN_BE_BURIED         = .{{ simulation.receivers_can_be_buried }}.
 
 # print source time function
-PRINT_SOURCE_TIME_FUNCTION      = .{{ simulation.print_source_time_function }}.
+PRINT_SOURCE_TIME_FUNCTION      = .false.
 

Modified: cs/portal/trunk/seismo/SeismoWebPortal/templates/SeismoWebPortal/parameters.pml
===================================================================
--- cs/portal/trunk/seismo/SeismoWebPortal/templates/SeismoWebPortal/parameters.pml	2008-04-04 14:28:06 UTC (rev 11752)
+++ cs/portal/trunk/seismo/SeismoWebPortal/templates/SeismoWebPortal/parameters.pml	2008-04-05 03:27:54 UTC (rev 11753)
@@ -8,20 +8,9 @@
         <facility name="model">{{ simulation.model.get_type_id }}</facility>
 
         <component name="solver">
-            <property name="simulation-type">{{ simulation.get_simulation_type_id }}</property>
-            <property name="save-forward">{{ simulation.save_forward }}</property>
             <property name="record-length">{{ simulation.record_length }}*minute</property>
             <property name="absorbing-conditions">{{ simulation.auto_absorbing_conditions }}</property>
-            <property name="movie-surface">{{ simulation.movie_surface }}</property>
-            <property name="movie-volume">{{ simulation.movie_volume }}</property>
-            <property name="ntstep-between-frames">{{ simulation.ntstep_between_frames }}</property>
-            <property name="hdur-movie">{{ simulation.hdur_movie }}</property>
-            <property name="number-of-runs">1</property>
-            <property name="number-of-this-run">1</property>
-            <property name="ntstep-between-output-info">{{ simulation.ntstep_between_output_info }}</property>
-            <property name="ntstep-between-output-seismos">{{ simulation.ntstep_between_output_seismos }}</property>
             <property name="receivers-can-be-buried">{{ simulation.receivers_can_be_buried }}</property>
-            <property name="print-source-time-function">{{ simulation.print_source_time_function }}</property>
         </component>
 
 
@@ -36,7 +25,6 @@
             <property name="nex-eta">{{ simulation.mesh.nex_eta }}</property>
             <property name="nproc-xi">{{ simulation.mesh.nproc_xi }}</property>
             <property name="nproc-eta">{{ simulation.mesh.nproc_eta }}</property>
-            <property name="save-files">{{ simulation.mesh.save_files }}</property>
         </component>
 
 

Modified: cs/portal/trunk/seismo/SeismoWebPortal/templates/SeismoWebPortal/single_source_event_form.html
===================================================================
--- cs/portal/trunk/seismo/SeismoWebPortal/templates/SeismoWebPortal/single_source_event_form.html	2008-04-04 14:28:06 UTC (rev 11752)
+++ cs/portal/trunk/seismo/SeismoWebPortal/templates/SeismoWebPortal/single_source_event_form.html	2008-04-05 03:27:54 UTC (rev 11753)
@@ -9,42 +9,6 @@
 
     <div class=tab30ex>
 
-    {% if object %}
-
-    <!-- PDE info is not used by the code -->
-    <input type="hidden" name="dataSource" value="{{ object.singleSource.dataSource }}">
-    <input type="hidden" name="when_date" value="{{ object.singleSource.when.date }}">
-    <input type="hidden" name="when_time" value="{{ object.singleSource.when.time }}">
-    <input type="hidden" name="microsecond" value="{{ object.singleSource.microsecond }}">
-    <input type="hidden" name="sourceLatitude" value="{{ object.singleSource.sourceLatitude }}">
-    <input type="hidden" name="sourceLongitude" value="{{ object.singleSource.sourceLongitude }}">
-    <input type="hidden" name="sourceDepth" value="{{ object.singleSource.sourceDepth }}">
-    <input type="hidden" name="sourceMB" value="{{ object.singleSource.sourceMB }}">
-    <input type="hidden" name="sourceMs" value="{{ object.singleSource.sourceMs }}">
-    <input type="hidden" name="region" value="{{ object.singleSource.region }}">
-
-    <input type="hidden" name="eventName" value="{{ object.singleSource.eventName }}"> <!-- redundant -->
-    <input type="hidden" name="timeShift" value="{{ object.singleSource.timeShift }}"> <!-- the solver will not run otherwise -->
-
-    {% else %}
-
-    <!-- PDE info is not used by the code -->
-    <input type="hidden" name="dataSource" value="ZZZ">
-    <input type="hidden" name="when_date" value="1900-1-1">
-    <input type="hidden" name="when_time" value="0:00:00">
-    <input type="hidden" name="microsecond" value="000000">
-    <input type="hidden" name="sourceLatitude" value="0.0">
-    <input type="hidden" name="sourceLongitude" value="0.0">
-    <input type="hidden" name="sourceDepth" value="0.0">
-    <input type="hidden" name="sourceMB" value="0.0">
-    <input type="hidden" name="sourceMs" value="0.0">
-    <input type="hidden" name="region" value="ZZZZ">
-
-    <input type="hidden" name="eventName" value="000000Z"> <!-- redundant -->
-    <input type="hidden" name="timeShift" value="0.0"> <!-- the solver will not run otherwise -->
-
-    {% endif %}
-
     <div>
         <label for="id_halfDuration" class=before>half duration</label>
         {{ form.halfDuration }} s

Modified: cs/portal/trunk/seismo/SeismoWebPortal/templates/SeismoWebPortal/source_detail.html
===================================================================
--- cs/portal/trunk/seismo/SeismoWebPortal/templates/SeismoWebPortal/source_detail.html	2008-04-04 14:28:06 UTC (rev 11752)
+++ cs/portal/trunk/seismo/SeismoWebPortal/templates/SeismoWebPortal/source_detail.html	2008-04-05 03:27:54 UTC (rev 11753)
@@ -9,5 +9,5 @@
 
 <div class=cmtsolution>
     <h3><code>CMTSOLUTION</code></h3>
-    <pre>{{ object.cmtSolution }}</pre>
+    <pre>{{ object.cmtSolutionText }}</pre>
 </div>

Modified: cs/portal/trunk/seismo/SeismoWebPortal/templates/SeismoWebPortal/specfem3dglobeparameters_detail.html
===================================================================
--- cs/portal/trunk/seismo/SeismoWebPortal/templates/SeismoWebPortal/specfem3dglobeparameters_detail.html	2008-04-04 14:28:06 UTC (rev 11752)
+++ cs/portal/trunk/seismo/SeismoWebPortal/templates/SeismoWebPortal/specfem3dglobeparameters_detail.html	2008-04-05 03:27:54 UTC (rev 11753)
@@ -10,15 +10,4 @@
         <dt>receivers at depth</dt><dd>{{ object.receivers_can_be_buried }}</dd>
     </dl>
 
-    {% if 0 %}
-    <div class=box>
-    <h3>movie</h3>
-    <dl>
-        <dt>create movie</dt><dd>{{ object.movie_surface }}</dd>
-        <dt>time steps between frames</dt><dd>{{ object.ntstep_between_frames }}</dd>
-        <dt>convolve source time function by Gaussian with half duration</dt><dd>{{ object.hdur_movie }}</dd>
-    </dl>
-    </div>
-    {% endif %}
-
 </div>

Modified: cs/portal/trunk/seismo/SeismoWebPortal/templates/SeismoWebPortal/specfem3dglobeparameters_form.html
===================================================================
--- cs/portal/trunk/seismo/SeismoWebPortal/templates/SeismoWebPortal/specfem3dglobeparameters_form.html	2008-04-04 14:28:06 UTC (rev 11752)
+++ cs/portal/trunk/seismo/SeismoWebPortal/templates/SeismoWebPortal/specfem3dglobeparameters_form.html	2008-04-05 03:27:54 UTC (rev 11753)
@@ -9,8 +9,6 @@
 
     <div class=tab30ex>
 
-    <input type="hidden" name="simulation_type" value="1">
-
     <div>
         <label for="id_mesh" class=before>mesh</label>
         {{ form.mesh }}
@@ -31,41 +29,6 @@
         {% if help_visible %}<span class=help>This flag accommodates stations with instruments that are buried, i.e., the solver will calculate seismograms at the burial depth specified in the station list.</span>{% endif %}
     </div>
 
-
-    {% if 0 %}
-    <fieldset><legend>movie</legend>
-
-    <div class=checkbox>
-        {{ form.movie_surface }}
-        <label for="id_movie_surface" class=after>create movie</label>
-        {% if form.movie_surface.errors %}<span class=error>{{ form.movie_surface.errors|join:", " }}</span>{% endif %}
-        {% if help_visible %}<span class=help>If selected, a movie of seismic wave propagation on the Earth's surface is created. Turning this option on generates large output files.</span>{% endif %}
-    </div>
-
-    <input type="hidden" name="movie_volume" value="False">
-
-    <div>
-        <label for="id_ntstep_between_frames" class=before>time steps between frames</label>
-        {{ form.ntstep_between_frames }}
-        {% if form.ntstep_between_frames.errors %}<span class=error>{{ form.ntstep_between_frames.errors|join:", " }}</span>{% endif %}
-        {% if help_visible %}<span class=help>Determines the number of timesteps between movie frames. Typically you want to  save a snapshot every 100 timesteps. The smaller you make this number, the more output will be generated!</span>{% endif %}
-    </div>
-
-    <div>
-        <label for="id_hdur_movie" class=before>convolve source time function by Gaussian with half duration</label>
-        {{ form.hdur_movie }}
-        {% if form.hdur_movie.errors %}<span class=error>{{ form.hdur_movie.errors|join:", " }}</span>{% endif %}
-        {% if help_visible %}<span class=help>Determines the half duration of the source time function for the movie simulations. When this parameter is set to zero, a default half duration that corresponds to the accuracy of the simulation is provided.</span>{% endif %}
-    </div>
-
-    </fieldset> <!-- movie -->
-
-    {% else %}
-    <input type="hidden" name="ntstep_between_frames" value="100">
-    <input type="hidden" name="hdur_movie" value="0">
-    {% endif %}
-
-
     <div><input class=submit type="submit" name="save" value="Save" />
     </div>
 

Modified: cs/portal/trunk/seismo/SeismoWebPortal/views.py
===================================================================
--- cs/portal/trunk/seismo/SeismoWebPortal/views.py	2008-04-04 14:28:06 UTC (rev 11752)
+++ cs/portal/trunk/seismo/SeismoWebPortal/views.py	2008-04-05 03:27:54 UTC (rev 11753)
@@ -1322,7 +1322,7 @@
 
 def eventFiles(name, event, request):
     index = Index({
-        "CMTSOLUTION.txt": (event_detail_cmtsolution_txt, (), dict(object_id = event.id)),
+        "CMTSOLUTION.txt": (event_detail_cmtsolution_txt, (), dict(event = event)),
         "beachball.gif": (beachball_gif, (), dict(event_id = event.id)),
         "gearth.kml": (event_detail_gearth, (), dict(object_id = event.id)),
         })
@@ -1367,7 +1367,6 @@
 def configSource(name, event, eventUrl, request, path, desktop):
     from models import Source
     from list_detail import object_detail
-    from create_update import update_object, delete_object
 
     appWindow = desktop.activeWindow
 
@@ -1594,7 +1593,7 @@
     return gearth_object_list(request,
                               queryset = event.source_set.all(),
                               template_name = 'SeismoWebPortal/event_detail_gearth.kml',
-                              extra_context = {'name': event.name},
+                              extra_context = {'name': 'XXX'},
                               )
 
 
@@ -1626,15 +1625,13 @@
     from models import Source
     source = get_object_or_404(Source, id=object_id)
     response = HttpResponse(mimetype='text/plain')
-    response.write(str(source.cmtSolution()))
+    response.write(source.cmtSolutionText())
     return response
 
-def event_detail_cmtsolution_txt(request, object_id):
+def event_detail_cmtsolution_txt(request, event):
 
     response = HttpResponse(mimetype='text/plain')
 
-    event = get_object_or_404(Event, id=object_id)
-
     count = event.source_set.count()
     for event in event.source_set.all():
         cmtSolution = CMTSolution.createFromDBModel(event)
@@ -1686,7 +1683,6 @@
 
 def configStationList(stationList, url, request, path, desktop):
     from list_detail import object_detail
-    from create_update import update_object
 
     objId = stationList.id # Ouch!
 



More information about the cig-commits mailing list