[cig-commits] r13302 - in cs/portal/trunk/northridge: . SeismoWebPortal SeismoWebPortal/templates/SeismoWebPortal

leif at geodynamics.org leif at geodynamics.org
Thu Nov 13 17:40:45 PST 2008


Author: leif
Date: 2008-11-13 17:40:45 -0800 (Thu, 13 Nov 2008)
New Revision: 13302

Added:
   cs/portal/trunk/northridge/SeismoWebPortal/templates/SeismoWebPortal/specfem3dglobemodel_confirm_delete.html
   cs/portal/trunk/northridge/SeismoWebPortal/templates/SeismoWebPortal/specfem3dglobemodel_detail.html
   cs/portal/trunk/northridge/SeismoWebPortal/templates/SeismoWebPortal/specfem3dglobemodel_form.html
   cs/portal/trunk/northridge/SeismoWebPortal/templates/SeismoWebPortal/specfem3dglobemodel_list.html
   cs/portal/trunk/northridge/SeismoWebPortal/templates/SeismoWebPortal/specfem3dglobemodel_upload.html
Modified:
   cs/portal/trunk/northridge/SeismoWebPortal/fformats.py
   cs/portal/trunk/northridge/SeismoWebPortal/management.py
   cs/portal/trunk/northridge/SeismoWebPortal/mezzanine.py
   cs/portal/trunk/northridge/SeismoWebPortal/models.py
   cs/portal/trunk/northridge/SeismoWebPortal/templates/SeismoWebPortal/par_file.txt
   cs/portal/trunk/northridge/SeismoWebPortal/templates/SeismoWebPortal/parameters.pml
   cs/portal/trunk/northridge/SeismoWebPortal/templates/SeismoWebPortal/pluggable.html
   cs/portal/trunk/northridge/SeismoWebPortal/templates/SeismoWebPortal/specfem3dglobeparameters_detail.html
   cs/portal/trunk/northridge/SeismoWebPortal/templates/SeismoWebPortal/specfem3dglobeparameters_list.html
   cs/portal/trunk/northridge/SeismoWebPortal/templates/SeismoWebPortal/splash.html
   cs/portal/trunk/northridge/setup.py
Log:
Added the basic stuff needed to upload 3D models.


Modified: cs/portal/trunk/northridge/SeismoWebPortal/fformats.py
===================================================================
--- cs/portal/trunk/northridge/SeismoWebPortal/fformats.py	2008-11-13 22:32:40 UTC (rev 13301)
+++ cs/portal/trunk/northridge/SeismoWebPortal/fformats.py	2008-11-14 01:40:45 UTC (rev 13302)
@@ -107,6 +107,18 @@
         return stationList
 
 
+class Specfem3DGlobeModelFormat:
+
+    def parse(self, stream):
+        return
+
+    def create(self, filename, stream):
+        model = models.Specfem3DGlobeModel(name = filename)
+        model.save_pathname_file(filename, stream.read(), False)
+        model.save()
+        return model
+
+
 class MineosModelFormat:
 
     def parse(self, stream):

Modified: cs/portal/trunk/northridge/SeismoWebPortal/management.py
===================================================================
--- cs/portal/trunk/northridge/SeismoWebPortal/management.py	2008-11-13 22:32:40 UTC (rev 13301)
+++ cs/portal/trunk/northridge/SeismoWebPortal/management.py	2008-11-14 01:40:45 UTC (rev 13302)
@@ -250,12 +250,16 @@
     # UserInfo
     cur.execute("select * from SeismoWebPortal_userinfo")
     for userInfo in cur:
-        userInfo = userInfo[0:8]
+        #userInfo = userInfo[0:8]
         (user_id,
          institution,
          address1, address2, address3, phone,
          ) = userInfo[0:6]
-        if len(userInfo) == 8:
+        role = 5 # other
+        adviser = ""
+        if len(userInfo) == 10:
+            role, adviser, invite_id, approved = userInfo[6:]
+        elif len(userInfo) == 8:
             invite_id, approved = userInfo[6:]
         else:
             # really old DB
@@ -270,6 +274,8 @@
             address2     = address2,
             address3     = address3,
             phone        = phone,
+            role         = role,
+            adviser      = adviser,
             invite       = invites[invite_id],
             approved     = approved,
             )
@@ -359,10 +365,11 @@
                                 m.nex_xi() < mesh.nex_xi())):
             # Select the lowest-resolution global mesh.
             mesh = m
-    if mesh:
-        parameters = models.Specfem3DGlobeParameters(mesh = mesh)
+    model = None # XXX
+    if mesh and model:
+        parameters = models.Specfem3DGlobeParameters(mesh = mesh, model = model)
         parameters.name = "%s all on, %.0fs Nex=%d" % (
-            parameters.get_model_display(),
+            model,
             mesh.shortestPeriod(),
             mesh.nex_xi(),
             )
@@ -399,8 +406,10 @@
     # runs
     stationList = models.StationList.userObjectList(user)[0][0]
     if recentEvent:
-        for parameters in [models.Specfem3DGlobeParameters.userObjectList(user)[0][0],
-                           models.MineosParameters.userObjectList(user)[0][0]]:
+        parameterSetList = []
+        parameterSetList.extend(models.Specfem3DGlobeParameters.userObjectList(user)[0][:1])
+        parameterSetList.extend(models.MineosParameters.userObjectList(user)[0][:1])
+        for parameters in parameterSetList:
             run = models.Run.objects.create(
                 event = recentEvent,
                 stationList = stationList,

Modified: cs/portal/trunk/northridge/SeismoWebPortal/mezzanine.py
===================================================================
--- cs/portal/trunk/northridge/SeismoWebPortal/mezzanine.py	2008-11-13 22:32:40 UTC (rev 13301)
+++ cs/portal/trunk/northridge/SeismoWebPortal/mezzanine.py	2008-11-14 01:40:45 UTC (rev 13302)
@@ -790,6 +790,19 @@
         return template
 
 
+class Specfem3DGlobeModel(Object):
+    Model = models.Specfem3DGlobeModel
+    FileFormat = fformats.Specfem3DGlobeModelFormat
+
+    creatable = False
+    uploadable = True
+    duplicatable = False
+
+    def changeManipulator(self, user):
+        object = self.obj
+        return self.Model.ChangeManipulator(getattr(object, object._meta.pk.attname), follow = dict(pathname = False))
+
+
 class Specfem3DGlobeParameters(Object):
     Model = models.Specfem3DGlobeParameters
 

Modified: cs/portal/trunk/northridge/SeismoWebPortal/models.py
===================================================================
--- cs/portal/trunk/northridge/SeismoWebPortal/models.py	2008-11-13 22:32:40 UTC (rev 13301)
+++ cs/portal/trunk/northridge/SeismoWebPortal/models.py	2008-11-14 01:40:45 UTC (rev 13302)
@@ -342,20 +342,6 @@
 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
 
-model_types = [
-    #   id (*)                        display name
-    ("transversely_isotropic_prem_plus_3D_crust_2.0", "crust2.0+prem"),
-    ("s20rts",                        "s20rts"),
-    ("s362ani",                       "s362ani"),
-    #("s362iso",                       "s362iso"), # undocumented
-    ("s362wmani",                     "s362wmani"),
-    ("s362ani_prem",                  "s362ani+prem"),
-    ("s29ea",                         "s29ea"),
-    # (*) ^^^ 'id' must be a name understood by the code
-]
-
-MODEL_TYPES = tuple([(num+1, model_types[num][1]) for num in xrange(0, len(model_types))])
-
 NCHUNKS_CHOICES = (
     (1, 'regional with 1 chunk'),
     (2, 'regional with 2 chunks'),
@@ -415,12 +401,20 @@
     nproc = property(lambda self: self.nchunks * self.nproc_xi * self.nproc_eta)
 
 
+class Specfem3DGlobeModel(Model, EditableObject):
+
+    name = models.CharField(maxlength=100)
+    pathname = models.FileField(upload_to="SeismoWebPortal/models")
+
+    def __str__(self): return self.name
+
+
 class Specfem3DGlobeParameters(Model, EditableObject):
 
     name = models.CharField(maxlength=100)
     
     mesh = models.ForeignKey(Specfem3DGlobeMesh)
-    model = models.IntegerField(choices=MODEL_TYPES, core=True, default=2)
+    model = models.ForeignKey(Specfem3DGlobeModel)
     oceans = models.BooleanField(core=True, default=True)
     gravity = models.BooleanField(core=True, default=True)
     attenuation = models.BooleanField(core=True, default=True)
@@ -446,9 +440,6 @@
         # allow this.
         return not self.mesh.nchunks == 6
 
-    def get_model_id(self):
-        return model_types[self.model-1][0]
-
     def runTime(self, run, cluster):
         mesh = self.mesh.archivalObject()
         perfSet = Specfem3DGlobePerformance.objects.filter(cluster = cluster, mesh = mesh)

Modified: cs/portal/trunk/northridge/SeismoWebPortal/templates/SeismoWebPortal/par_file.txt
===================================================================
--- cs/portal/trunk/northridge/SeismoWebPortal/templates/SeismoWebPortal/par_file.txt	2008-11-13 22:32:40 UTC (rev 13301)
+++ cs/portal/trunk/northridge/SeismoWebPortal/templates/SeismoWebPortal/par_file.txt	2008-11-14 01:40:45 UTC (rev 13302)
@@ -22,17 +22,6 @@
 NPROC_XI                        = {{ parameters.mesh.nproc_xi }}
 NPROC_ETA                       = {{ parameters.mesh.nproc_eta }}
 
-# 1D models with real structure:
-# 1D_isotropic_prem, 1D_transversely_isotropic_prem, 1D_iasp91, 1D_1066a, 1D_ak135, 1D_ref, 1D_ref_iso
-#
-# 1D models with only one fictitious averaged crustal layer:
-# 1D_isotropic_prem_onecrust, 1D_transversely_isotropic_prem_onecrust, 1D_iasp91_onecrust, 1D_1066a_onecrust, 1D_ak135_onecrust
-#
-# fully 3D models:
-# transversely_isotropic_prem_plus_3D_crust_2.0, 3D_anisotropic, 3D_attenuation,
-# s20rts, s362ani, s362iso, s362wmani, s362ani_prem, s29ea
-MODEL                           = {{ parameters.get_model_id }}
-
 # parameters describing the Earth model
 OCEANS                          = .{{ parameters.oceans }}.
 ELLIPTICITY                     = .{{ parameters.ellipticity }}.

Modified: cs/portal/trunk/northridge/SeismoWebPortal/templates/SeismoWebPortal/parameters.pml
===================================================================
--- cs/portal/trunk/northridge/SeismoWebPortal/templates/SeismoWebPortal/parameters.pml	2008-11-13 22:32:40 UTC (rev 13301)
+++ cs/portal/trunk/northridge/SeismoWebPortal/templates/SeismoWebPortal/parameters.pml	2008-11-14 01:40:45 UTC (rev 13302)
@@ -5,7 +5,6 @@
 <inventory>
 
     <component name="Specfem3DGlobe">
-        <facility name="model">{{ parameters.get_model_id }}</facility>
 
         <component name="solver">
             <property name="record-length">{{ parameters.record_length }}*minute</property>

Modified: cs/portal/trunk/northridge/SeismoWebPortal/templates/SeismoWebPortal/pluggable.html
===================================================================
--- cs/portal/trunk/northridge/SeismoWebPortal/templates/SeismoWebPortal/pluggable.html	2008-11-13 22:32:40 UTC (rev 13301)
+++ cs/portal/trunk/northridge/SeismoWebPortal/templates/SeismoWebPortal/pluggable.html	2008-11-14 01:40:45 UTC (rev 13302)
@@ -26,7 +26,7 @@
                 <thead>
                 <tr>
                     <th align=left colspan=4></th>
-                    <th class="Specfem3DGlobe" align=left colspan=2><div class="tab">3D ~ Specfem 3D Globe</div></th>
+                    <th class="Specfem3DGlobe" align=left colspan=3><div class="tab">3D ~ Specfem 3D Globe</div></th>
                     <th class="Mineos" align=left colspan=3><div class="tab">1D ~ Mineos</div></th>
                 </tr>
                 </thead>
@@ -56,6 +56,10 @@
                         <a href="{{root}}/?class=Specfem3DGlobeMesh"><img src="{{root}}/images/mesh.gif" width=32 height=32><br>
                         Meshes</a>
                     </td>
+                    <td class="Specfem3DGlobe" align=center>
+                        <a href="{{root}}/?class=Specfem3DGlobeModel"><img src="{{root}}/images/prem.gif" width=32 height=32><br>
+                        3D Models</a>
+                    </td>
                     <td class="Mineos" align=center>
                         <a href="{{root}}/?class=MineosParameters"><img src="{{root}}/images/parameters.gif" width=32 height=32><br>
                         1D Parameters</a>

Added: cs/portal/trunk/northridge/SeismoWebPortal/templates/SeismoWebPortal/specfem3dglobemodel_confirm_delete.html
===================================================================
--- cs/portal/trunk/northridge/SeismoWebPortal/templates/SeismoWebPortal/specfem3dglobemodel_confirm_delete.html	                        (rev 0)
+++ cs/portal/trunk/northridge/SeismoWebPortal/templates/SeismoWebPortal/specfem3dglobemodel_confirm_delete.html	2008-11-14 01:40:45 UTC (rev 13302)
@@ -0,0 +1,10 @@
+
+<h2><img src="{{root}}/images/prem.gif" width=32 height=32> Delete Specfem 3D Globe Model</h2>
+
+<form method="post" action="{{action}}">
+    <input type="hidden" name="class" value="Specfem3DGlobeModel">
+    <input type="hidden" name="object" value="{{object.id}}">
+    <input type="hidden" name="action" value="delete">
+    <p>Are you sure you want to delete the model "{{ object }}"?
+    <p><input type="submit" value="Delete" />
+</form>

Added: cs/portal/trunk/northridge/SeismoWebPortal/templates/SeismoWebPortal/specfem3dglobemodel_detail.html
===================================================================
--- cs/portal/trunk/northridge/SeismoWebPortal/templates/SeismoWebPortal/specfem3dglobemodel_detail.html	                        (rev 0)
+++ cs/portal/trunk/northridge/SeismoWebPortal/templates/SeismoWebPortal/specfem3dglobemodel_detail.html	2008-11-14 01:40:45 UTC (rev 13302)
@@ -0,0 +1,6 @@
+
+<h2><img src="{{root}}/images/prem.gif" width=32 height=32> {{ object }}</h2>
+
+<pre>
+{{ object.pathname }}
+</pre>

Added: cs/portal/trunk/northridge/SeismoWebPortal/templates/SeismoWebPortal/specfem3dglobemodel_form.html
===================================================================
--- cs/portal/trunk/northridge/SeismoWebPortal/templates/SeismoWebPortal/specfem3dglobemodel_form.html	                        (rev 0)
+++ cs/portal/trunk/northridge/SeismoWebPortal/templates/SeismoWebPortal/specfem3dglobemodel_form.html	2008-11-14 01:40:45 UTC (rev 13302)
@@ -0,0 +1,27 @@
+
+<h2><img src="{{root}}/images/prem.gif" width=32 height=32> Rename Specfem 3D Globe Model</h2>
+
+{% if form.has_errors %}
+<p><span class=error>Please correct the following error{{ form.error_dict|pluralize }}.</span>
+{% endif %}
+
+<form method="post" action="{{action}}">
+    <input type="hidden" name="class" value="Specfem3DGlobeModel">
+    <input type="hidden" name="object" value="{{object.id}}">
+    <input type="hidden" name="action" value="edit">
+
+    <div class=tab30ex>
+
+    <div>
+        <label for="id_name" class=before>name</label>
+        {{ form.name }}
+        {% if form.name.errors %}<span class=error>{{ form.name.errors|join:", " }}</span>{% endif %}
+    </div>
+
+    <div>
+        <input class=submit type="submit" value="Save">
+    </div>
+
+    </div> <!-- tab30ex -->
+
+</form>

Added: cs/portal/trunk/northridge/SeismoWebPortal/templates/SeismoWebPortal/specfem3dglobemodel_list.html
===================================================================
--- cs/portal/trunk/northridge/SeismoWebPortal/templates/SeismoWebPortal/specfem3dglobemodel_list.html	                        (rev 0)
+++ cs/portal/trunk/northridge/SeismoWebPortal/templates/SeismoWebPortal/specfem3dglobemodel_list.html	2008-11-14 01:40:45 UTC (rev 13302)
@@ -0,0 +1,24 @@
+
+<h2><img src="{{root}}/images/prem.gif" width=32 height=32> 3D Models</h2>
+
+{% if object_list %}
+
+<table rules=cols class="clickable">
+    <thead>
+    <tr>
+        <th>name</th>
+    </tr>
+    </thead>
+
+    <tbody>
+    {% for object in object_list %}
+    <tr class="{% cycle odd,even %}" id="o{{object.id}}" onclick="location.href='{{root}}/?class=Specfem3DGlobeModel&object={{object.id}}'">
+        <td><a href="{{root}}/?class=Specfem3DGlobeModel&object={{object.id}}">{{ object }}</a></td>
+    </tr>
+    {% endfor %}
+    </tbody>
+</table>
+
+{% else %}
+    <p>You have no Specfem 3D Globe models.
+{% endif %}

Added: cs/portal/trunk/northridge/SeismoWebPortal/templates/SeismoWebPortal/specfem3dglobemodel_upload.html
===================================================================
--- cs/portal/trunk/northridge/SeismoWebPortal/templates/SeismoWebPortal/specfem3dglobemodel_upload.html	                        (rev 0)
+++ cs/portal/trunk/northridge/SeismoWebPortal/templates/SeismoWebPortal/specfem3dglobemodel_upload.html	2008-11-14 01:40:45 UTC (rev 13302)
@@ -0,0 +1,26 @@
+
+<h2><img src="{{root}}/images/prem.gif" width=32 height=32> Upload Specfem 3D Globe Model</h2>
+
+<form action="{{action}}" method="POST" enctype="multipart/form-data">
+    <input type="hidden" name="class" value="Specfem3DGlobeModel">
+    <input type="hidden" name="action" value="upload">
+
+    {% if form.has_errors %}
+    <p><span class=error>Please correct the following error{{ form.error_dict|pluralize }}.</span>
+    {% endif %}
+
+    <div class=tab30ex>
+
+    <div>
+        <label for="id_file" class=before>local file to upload</label>
+        {{ form.file }} {{ form.file_file }}
+        {% if form.file.errors %}<span class=error>{{ form.file.errors|join:", " }}</span>{% endif %}
+    </div>
+
+    <div>
+        <input class=submit type="submit" value="Upload">
+    </div>
+
+    </div> <!-- tab30ex -->
+
+</form>

Modified: cs/portal/trunk/northridge/SeismoWebPortal/templates/SeismoWebPortal/specfem3dglobeparameters_detail.html
===================================================================
--- cs/portal/trunk/northridge/SeismoWebPortal/templates/SeismoWebPortal/specfem3dglobeparameters_detail.html	2008-11-13 22:32:40 UTC (rev 13301)
+++ cs/portal/trunk/northridge/SeismoWebPortal/templates/SeismoWebPortal/specfem3dglobeparameters_detail.html	2008-11-14 01:40:45 UTC (rev 13302)
@@ -3,7 +3,7 @@
 
 <dl class=parameters>
     <dt>mesh</dt><dd><a href="{{root}}/?class=Specfem3DGlobeMesh&object={{object.mesh.id}}">{{ object.mesh }}</a></dd>
-    <dt>model</dt><dd>{{ object.get_model_display }}</dd>
+    <dt>model</dt><dd><a href="{{root}}/?class=Specfem3DGlobeModel&object={{object.model.id}}">{{ object.model }}</a></dd>
     <dt>oceans</dt><dd>{{ object.oceans }}</dd>
     <dt>gravity</dt><dd>{{ object.gravity }}</dd>
     <dt>attenuation</dt><dd>{{ object.attenuation }}</dd>

Modified: cs/portal/trunk/northridge/SeismoWebPortal/templates/SeismoWebPortal/specfem3dglobeparameters_list.html
===================================================================
--- cs/portal/trunk/northridge/SeismoWebPortal/templates/SeismoWebPortal/specfem3dglobeparameters_list.html	2008-11-13 22:32:40 UTC (rev 13301)
+++ cs/portal/trunk/northridge/SeismoWebPortal/templates/SeismoWebPortal/specfem3dglobeparameters_list.html	2008-11-14 01:40:45 UTC (rev 13302)
@@ -23,7 +23,7 @@
             <td><a href="{{root}}/?class=Specfem3DGlobeParameters&object={{object.id}}">{{ object }}</a></td>
             <td>{{ object.mesh }}<br>
                 <span class=inlineInfo>shortest period &cong; {{ object.mesh.shortestPeriod|stringformat:".0f" }}s</span></td>
-            <td>{{ object.get_model_display }}</td>
+            <td>{{ object.model }}</td>
             <td><img src="{{root}}/images/icon-{% if object.oceans %}yes{% else %}no{% endif %}.gif" alt="{{ object.oceans }}"></td>
             <td><img src="{{root}}/images/icon-{% if object.gravity %}yes{% else %}no{% endif %}.gif" alt="{{ object.gravity }}"></td>
             <td><img src="{{root}}/images/icon-{% if object.attenuation %}yes{% else %}no{% endif %}.gif" alt="{{ object.attenuation }}"></td>

Modified: cs/portal/trunk/northridge/SeismoWebPortal/templates/SeismoWebPortal/splash.html
===================================================================
--- cs/portal/trunk/northridge/SeismoWebPortal/templates/SeismoWebPortal/splash.html	2008-11-13 22:32:40 UTC (rev 13301)
+++ cs/portal/trunk/northridge/SeismoWebPortal/templates/SeismoWebPortal/splash.html	2008-11-14 01:40:45 UTC (rev 13302)
@@ -7,7 +7,7 @@
 
     <h1><img src="{{root}}/images/cig.gif"> <img src="{{root}}/images/seismogram.gif"><br>CIG Seismology Web Portal</h1>
 
-    <p>Version 3.2.1</p>
+    <p>Version 3.3.0</p>
 
     <hr>
 

Modified: cs/portal/trunk/northridge/setup.py
===================================================================
--- cs/portal/trunk/northridge/setup.py	2008-11-13 22:32:40 UTC (rev 13301)
+++ cs/portal/trunk/northridge/setup.py	2008-11-14 01:40:45 UTC (rev 13302)
@@ -3,7 +3,7 @@
 
 setup(
     name = 'SeismoWebPortal', 
-    version = '3.2.1',
+    version = '3.3.0',
     url = 'http://www.geodynamics.org/',
     author = 'Leif Strand',
     author_email = 'leif at geodynamics.org',



More information about the CIG-COMMITS mailing list