]> git.donarmstrong.com Git - neurodebian.git/commitdiff
initial redo of the ratings with too much fanciness
authorYaroslav Halchenko <debian@onerussian.com>
Tue, 17 May 2011 13:01:17 +0000 (09:01 -0400)
committerYaroslav Halchenko <debian@onerussian.com>
Tue, 17 May 2011 13:08:17 +0000 (09:08 -0400)
survey/makestats
survey/results.rst

index 1cac0dcbefaa7a040b3717d6342cd2b31e944e23..44b133c70654c99749709d4e069b1f7e87968649 100755 (executable)
@@ -180,7 +180,7 @@ class DB(dict):
         srcs = [DB.os_dict, os_cat_names, DB.sw_dict, sw_categories,
                 resource_categories, time_categories,
                 DB.datamod_dict, DB.position_dict, DB.employer_dict,
-                DB.vm_dict]
+                DB.vm_dict, DB.ratings_dict]
         for src in srcs:
             if id in src:
                 return src[id]
@@ -311,34 +311,93 @@ def mkpic_rating_by_os(db, env, items, destdir, title):
     pl.legend(loc='lower right')
     pl.savefig('%s/ratings_%s.png' % (destdir, env), format='png', dpi=80)
 
-def mkpic_rating_by_os_hor(db, env, items, destdir, title):
-    envs = ['pers_time', 'man_time', 'virt_time']
-    env_names = ['Personal', 'Managed', 'Virtual']
-    env_stats = {}
-    for env in envs:
-        counts = dict(zip(time_order, [0] * len(time_order)))
-        counts.update(db.get_counts(env))
-        total_count = np.sum(counts.values())
-        for c in counts:
-            counts[c] = float(counts[c]) / total_count
-        env_stats[env] = counts
-    # make stacked barplot
-    pl.figure(figsize=(7.5, 4))
-    x = np.arange(len(envs))
-    bottoms = np.zeros(len(envs))
-    for i, t in enumerate(time_order):
-        stat = [env_stats[e][t] for e in envs]
+def mkpic_rating_by_os_hor_joined(db, env, items, destdir, title,
+                                  intro_sentence="I agree with the statements"):
+    per_os_width = 10
+    max_rating = 4
+    #pl.figure(figsize=(6.4, 4.8))
+    nos = len(os_order)
+    rst = open('figures/ratings_%s.rst' % env, 'w')
+    rst.write("""
+
+%s
+%s
+
+%s
+
+.. raw:: html
+
+   <table>
+    """ % (title, '=' * len(title), intro_sentence))
+    for k, it in enumerate(items):
+        pl.figure(figsize=(3.2, 0.5))
+        it_nice = db.get_nice_name(it)#.lstrip('.').lstrip(' ')
+        it_nice = it_nice[0].upper() + it_nice[1:]
+        for i, os in enumerate(os_order):
+            ratings = np.array(db.select_match(env,
+                                               os_family[os]).get_not_none('%s' % (it,))[0])
+            # assume that we have 4 grades from 0 to 3
+            if len(ratings):
+                assert(max(ratings) < max_rating)
+            total = len(ratings)
+            bottom = 0
+            for r in range(max_rating)[::-1]: # so we go from agree to don't
+                stat = np.sum(ratings == r) * per_os_width / float(total)
+                #print r, it, os, stat, total
+                #if it == "pers_r8" and os == "linux" and r == 3:
+                #    import pydb; pydb.debugger()
+                kwargs = dict(label=None)
+                if stat:
+                    pl.barh(1.0/nos * (nos - 1 - i), stat, left=bottom, color=os_colors[i],
+                            height=.25, alpha=0.25 + r/float(max_rating),
+                            label=None,
+                            edgecolor=os_colors[i])
+                bottom += stat
+            # Complement with errorbar
+            if len(ratings):
+                meanstat = np.mean(ratings)
+                errstat = len(ratings) > 1 and np.std(ratings) or 0
+                pl.errorbar([per_os_width * (max_rating-1 - float(meanstat))/(max_rating-1)],
+                            [1.0/nos * (nos - 0.5 - i)],
+                            xerr=[errstat], fmt='o', color=os_colors[i], ecolor='k')
+        #plot_bars(ratings, offset=((i+1)*0.2)-0.1, color=os_colors[i],
+        #          title=title, ylabel="Mean rating", label=db.get_nice_name(os))
         #import pydb; pydb.debugger()
-        pl.barh(x, stat, left=bottoms, color=time_colors[i],
-               label=db.get_nice_name(t), height=.6, alpha=0.25 + i/4.0)
-        bottoms += stat
-    pl.legend(loc='center left')
-    pl.yticks(x + 0.2,  env_names)
-    pl.ylim(-0.4, len(envs))
-    pl.title("Research activity time by environment")
-    pl.xlabel("Fraction of submissions")
-    pl.subplots_adjust(right=0.97)
-    pl.savefig('%s/time_by_env.png' % destdir, format='png', dpi=80)
+        #pl.xlim((0, per_os_width * len(os_order)))
+        #pl.ylim((0, 1)) # len(items)))
+        #pl.yticks((0, 3), ['Disagree', 'Agree'], rotation=90)
+        #pl.xticks(np.arange(len(items))+0.5, [i[-2:] for i in items],
+        #          horizontalalignment='center')
+        #pl.legend(loc='lower right')
+        pl.xlim((0, per_os_width))
+        pl.ylim((0, 1))
+        pl.axis('off')
+        pl.subplots_adjust(left=0.01, right=0.99, bottom=0.0, top=1,
+                       wspace=0.05, hspace=0.05)
+        fname = '%s/ratings_%s_%s.png' % (destdir, env, it)
+        pl.savefig(fname, format='png', dpi=80)
+        pl.close()
+        oddrow_s = k % 2 == 0 and ' class="oddrow"' or ''
+        rst.write("""
+        <tr%(oddrow_s)s>
+        <td class="task">%(it_nice)s</td>
+        <td class="response"> <div class="figure"><img border=0 alt="%(fname)s" src="%(fname)s" /> </div> </td> </tr>"""
+                  % (locals()))
+
+    #pl.yticks(range(len(items)),  [db.get_nice_name(it) for it in items])
+    #pl.xlim((0, per_os_width))# * len(os_order)))
+    #pl.ylim((0, len(items)))
+    #pl.axis('off')
+    #pl.subplots_adjust(left=0, right=1, bottom=0, top=1,
+    #                   wspace=0.05, hspace=0.05)
+    #pl.savefig('%s/ratings_%s.png' % (destdir, env), format='png', dpi=80)
+    #pl.close()
+    rst.write("""
+    </table>
+
+    """)
+    rst.close()
+    return
 
 
 def main(srcdir, destdir):
@@ -368,12 +427,19 @@ def main(srcdir, destdir):
 
     for pic in [mkpic_os_per_env, mkpic_software, mkpic_time_per_env]:
         pic(db, destdir)
-    mkpic_rating_by_os(db, 'pers_os', ['pers_r%i' % i for i in range(1, 9)], destdir,
-                       "Ratings: Personal environment")
-    mkpic_rating_by_os(db, 'man_os', ['man_r%i' % i for i in range(1, 5)], destdir,
-                       "Ratings: Managed environment")
-    mkpic_rating_by_os(db, 'virt_host_os', ['virt_r%i' % i for i in range(1, 4)], destdir,
-                       "Ratings: Virtual environment (by host OS)")
+    mkpic_rating_by_os_hor_joined(db, 'pers_os', ['pers_r%i' % i for i in range(1, 9)], destdir,
+                       "Personal environment", "I prefer this particular scientific software environment because ...")
+    mkpic_rating_by_os_hor_joined(db, 'man_os', ['man_r%i' % i for i in range(1, 5)], destdir,
+                       "Managed environment")
+    mkpic_rating_by_os_hor_joined(db, 'virt_host_os', ['man_r%i' % i for i in range(1, 4)], destdir,
+                       "Virtual environment (by host OS)")
+
+    ## mkpic_rating_by_os(db, 'pers_os', ['pers_r%i' % i for i in range(1, 9)], destdir,
+    ##                    "Ratings: Personal environment")
+    ## mkpic_rating_by_os(db, 'man_os', ['man_r%i' % i for i in range(1, 5)], destdir,
+    ##                    "Ratings: Managed environment")
+    ## mkpic_rating_by_os(db, 'virt_host_os', ['virt_r%i' % i for i in range(1, 4)], destdir,
+    ##                    "Ratings: Virtual environment (by host OS)")
     # submission stats: this is RST
     statsfile = open('%s/stats.txt' % destdir, 'w')
     statsfile.write('::\n\n  Number of submissions: %i\n' % len(db))
index 9195183f1e6a76c63d873b5ae2e293d6ccf9ea63..3e7607799aea39243e6c3af47890428625cd88c8 100644 (file)
@@ -18,9 +18,14 @@ Scientific computing environment preferences
 .. figure:: figures/ospref_by_env.png
 .. figure:: figures/time_by_env.png
 
-.. figure:: figures/ratings_pers_os.png
-.. figure:: figures/ratings_man_os.png
-.. figure:: figures/ratings_virt_host_os.png
+
+Environment ratings
+~~~~~~~~~~~~~~~~~~~
+
+.. include:: figures/ratings_pers_os.rst
+.. include:: figures/ratings_man_os.rst
+.. include:: figures/ratings_virt_host_os.rst
+
 
 Software resources
 ~~~~~~~~~~~~~~~~~~