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

leif at geodynamics.org leif at geodynamics.org
Thu Mar 19 14:50:52 PDT 2009


Author: leif
Date: 2009-03-19 14:50:52 -0700 (Thu, 19 Mar 2009)
New Revision: 14394

Added:
   cs/portal/trunk/northridge/drop-all-tables.sql
Modified:
   cs/portal/trunk/northridge/SeismoWebPortal/__init__.py
   cs/portal/trunk/northridge/SeismoWebPortal/management.py
   cs/portal/trunk/northridge/SeismoWebPortal/models.py
Log:
These are various tweaks I made while attempting to migrate from
SQLite to MySQL.  There are a number of glitches associated with
FloatFields.  The most problematic is the following: because of the
new DB backend, FloatFields are now seen by the Python code as
decimal.Decimal's instead of floats.  Among other things, this messes
up the formatting in at least a dozen places (a default record length
of "20.0000000000" looks silly).  I might try PostgreSQL to see if it
is any different.


Modified: cs/portal/trunk/northridge/SeismoWebPortal/__init__.py
===================================================================
--- cs/portal/trunk/northridge/SeismoWebPortal/__init__.py	2009-03-19 20:55:27 UTC (rev 14393)
+++ cs/portal/trunk/northridge/SeismoWebPortal/__init__.py	2009-03-19 21:50:52 UTC (rev 14394)
@@ -0,0 +1,24 @@
+
+from django.conf import settings
+
+if settings.DATABASE_ENGINE == 'mysql' and settings.DEBUG:
+    # django.db.backends.mysql.base.DatabaseWrapper goes bananas when
+    # DEBUG is True, adding a new global "error" filter everytime
+    # cursor() is called.
+    
+    # In the first place, treating warnings as exceptions can be
+    # annoying (even in debug mode): "Warning: Data truncated for
+    # column 'timeFactor' at row 1".  Oooo, a floating-point value is
+    # being truncated.  Like I care.
+    
+    # New filters are constantly being added by DatabaseWrapper,
+    # quickly drowning any filter we might add to override the
+    # annoying behavior.  Therefore, we patch 'filterwarnings' itself,
+    # turning it into a no-op.
+    
+    def squash(*args, **kwds):
+        #print "@@@ SQUASH", args, kwds
+        return
+    import warnings
+    warnings.filterwarnings = squash
+    #print "@@@", warnings.filters

Modified: cs/portal/trunk/northridge/SeismoWebPortal/management.py
===================================================================
--- cs/portal/trunk/northridge/SeismoWebPortal/management.py	2009-03-19 20:55:27 UTC (rev 14393)
+++ cs/portal/trunk/northridge/SeismoWebPortal/management.py	2009-03-19 21:50:52 UTC (rev 14394)
@@ -168,11 +168,11 @@
     meshes = [mesh.archivalObject() for mesh in models.Specfem3DGlobeMesh.builtInObjectList()]
 
     perfData = {
-        #                    overhead     timeFactor     stationFactor
-        (lonestar, 6, 160): (     6.0, 3.90919581078, 0.0122251748901 ),
-        (lonestar, 6, 240): (     6.0, 6.40830686286, 0.0122251748901 ),
-        (ciTerra,  6, 160): (     6.0, 5.09329515444, 0.00902156376639),
-        (ciTerra,  6, 240): (     6.0, 8.16250993666, 0.00902156376639),
+        #                    overhead  timeFactor    stationFactor
+        (lonestar, 6, 160): (     6.0, 3.9091958108, 0.0122251749 ),
+        (lonestar, 6, 240): (     6.0, 6.4083068629, 0.0122251749 ),
+        (ciTerra,  6, 160): (     6.0, 5.0932951544, 0.0090215638 ),
+        (ciTerra,  6, 240): (     6.0, 8.1625099367, 0.0090215638 ),
         }
 
     for cluster in clusters:

Modified: cs/portal/trunk/northridge/SeismoWebPortal/models.py
===================================================================
--- cs/portal/trunk/northridge/SeismoWebPortal/models.py	2009-03-19 20:55:27 UTC (rev 14393)
+++ cs/portal/trunk/northridge/SeismoWebPortal/models.py	2009-03-19 21:50:52 UTC (rev 14394)
@@ -163,12 +163,12 @@
     latitude = models.FloatField(max_digits=19, decimal_places=10)
     longitude = models.FloatField(max_digits=19, decimal_places=10)
     depth = models.FloatField(max_digits=19, decimal_places=10)
-    Mrr = models.FloatField(max_digits=19, decimal_places=10)
-    Mtt = models.FloatField(max_digits=19, decimal_places=10)
-    Mpp = models.FloatField(max_digits=19, decimal_places=10)
-    Mrt = models.FloatField(max_digits=19, decimal_places=10)
-    Mrp = models.FloatField(max_digits=19, decimal_places=10)
-    Mtp = models.FloatField(max_digits=19, decimal_places=10)
+    Mrr = models.FloatField(max_digits=40, decimal_places=10)
+    Mtt = models.FloatField(max_digits=40, decimal_places=10)
+    Mpp = models.FloatField(max_digits=40, decimal_places=10)
+    Mrt = models.FloatField(max_digits=40, decimal_places=10)
+    Mrp = models.FloatField(max_digits=40, decimal_places=10)
+    Mtp = models.FloatField(max_digits=40, decimal_places=10)
 
     def __str__(self): return self.eventName
 
@@ -206,7 +206,8 @@
 
     def scalarSeismicMoment(self):
         """Return the scalar seismic moment in dyne cm."""
-        return ((self.Mrr**2 + self.Mtt**2 + self.Mpp**2 + 2*(self.Mrt**2 + self.Mrp**2 + self.Mtp**2)) / 2)**0.5
+        from math import sqrt
+        return sqrt((self.Mrr**2 + self.Mtt**2 + self.Mpp**2 + 2*(self.Mrt**2 + self.Mrp**2 + self.Mtp**2)) / 2)
 
     def momentMagnitude(self):
         """Return the moment magnitude, Mw."""
@@ -1018,8 +1019,11 @@
         return max(self.totalSUs() - self.usedSUs(), 0)
 
     def availableSUsPx154(self):
-        avail = float(self.availableSUs()) / float(self.totalSUs())
         imageWidth = 154
+        totalSUs = self.totalSUs()
+        if totalSUs == 0:
+            return imageWidth
+        avail = float(self.availableSUs()) / float(totalSUs)
         offset = imageWidth - int(float(imageWidth) * avail)
         if offset < 0:
             offset = 0

Added: cs/portal/trunk/northridge/drop-all-tables.sql
===================================================================
--- cs/portal/trunk/northridge/drop-all-tables.sql	                        (rev 0)
+++ cs/portal/trunk/northridge/drop-all-tables.sql	2009-03-19 21:50:52 UTC (rev 14394)
@@ -0,0 +1,37 @@
+drop table SeismoWebPortal_archive;
+drop table SeismoWebPortal_archivedrun;
+drop table SeismoWebPortal_archivedsource;
+drop table SeismoWebPortal_award;
+drop table SeismoWebPortal_builtin;
+drop table SeismoWebPortal_cluster;
+drop table SeismoWebPortal_datasource;
+drop table SeismoWebPortal_event;
+drop table SeismoWebPortal_invite;
+drop table SeismoWebPortal_job;
+drop table SeismoWebPortal_mineosmodecatalog;
+drop table SeismoWebPortal_mineosmodel;
+drop table SeismoWebPortal_mineosparameters;
+drop table SeismoWebPortal_outputfile;
+drop table SeismoWebPortal_ownership;
+drop table SeismoWebPortal_region;
+drop table SeismoWebPortal_run;
+drop table SeismoWebPortal_source;
+drop table SeismoWebPortal_specfem3dglobemesh;
+drop table SeismoWebPortal_specfem3dglobemodel;
+drop table SeismoWebPortal_specfem3dglobeparameters;
+drop table SeismoWebPortal_specfem3dglobeperformance;
+drop table SeismoWebPortal_station;
+drop table SeismoWebPortal_stationlist;
+drop table SeismoWebPortal_stationnetwork;
+drop table SeismoWebPortal_userinfo;
+drop table auth_group;
+drop table auth_group_permissions;
+drop table auth_message;
+drop table auth_permission;
+drop table auth_user;
+drop table auth_user_groups;
+drop table auth_user_user_permissions;
+drop table django_admin_log;
+drop table django_content_type;
+drop table django_session;
+drop table django_site;



More information about the CIG-COMMITS mailing list