In [1]:
# This cell loads the data that was calculated by Volker Braun, Thomas W. Grimm and Jan Keitel in
# http://arxiv.org/abs/1411.2615.
#
# - IMPORTANT -
# You first have to obtain the data in the following way:
# 1) Go to http://wwwth.mpp.mpg.de/members/jkeitel/Weierstrass/info.html
# 2) Download the full dataset, i.e. nefs.tar.gz
# 3) Extract all of the files into a folder "nefs" located in the same directory as your worksheet.
#
# The resulting dictionary "data" is indexed by tuples (polyId, dataId) and the items are lists of the form
#
# [ 
#   (# toric U(1)s, degree of toric Mordell-Weil torsion),
#   [codimension 1 singularities with I_n fibers, codimension 1 singularities with I_n* fibers],
#   [equation 1, equation 2],
#   is_product_flag
# ]
#
# The dictionary is saved into the file "data1411_2615.txt".
#

import re

import os
import mmap

data = {}

for subdir, dirs, files in os.walk(os.path.join(os.getcwd(),'nefs')):
  
    for filename in files:
      
        polyId = int(filename.replace('_', '.').split('.')[0])
        nefId = int(filename.replace('_', '.').split('.')[1])
      
        filepath = os.path.join(subdir,filename)

        f = open(filepath, "r")
        
        numToricU1 = 0
        degMWTorsion = 1
        nonAbelianGS_simple = []
        nonAbelianGS_special = []
        
        product = False
        
        for i in range(7):
            
            f.readline()
            
        line = f.readline()
        
        if 'Toric Mordell-Weil group' in line:
        
            for i in range(3):
            
                f.readline()
        
            line = f.readline().replace('\n', '')
            splitline = line.split(' ')
            
            if len(splitline) == 3:
                
                if splitline[2][1] == '^':
                    
                    numToricU1 = int(splitline[2][2])
                    
                else:
                    
                    degMWTorsion = int(splitline[2][2])
            
            elif len(splitline) == 5:
                
                numToricU1 = int(splitline[2][2])
                degMWTorsion = int(splitline[4][2])

        while not 'Complete intersection' in line:
        
            line = f.readline()
            
        eq1 = f.readline().replace('\n', '')
        eq2 = f.readline().replace('\n', '')

        while not 'non-Abelian' in line:
        
            line = f.readline()
            
        if "for a study of the study" in line:
            
            product = True
        
        if 'Generic' in line:
            
            for line in f:
                
                naString = line.split(',')[3]
                locus = line.split(':')[0]
                
                nontoric = len(re.findall('a\d+', locus)) > 1
                
                if not '*' in naString:
                
                    nonAbelianGS_simple.append([int(naString[3]), locus, nontoric])
                    
                else:
                    
                    nonAbelianGS_special.append([naString[1:].replace('\n', ''), locus, nontoric])

        data[(polyId, nefId)] = [(numToricU1, degMWTorsion), [nonAbelianGS_simple, nonAbelianGS_special], [eq1, eq2], product]
        
with open("data1411_2615.txt", "w") as f:
    
    f.write("{\n")
    
    for item in sorted(sorted(data.items(), key=lambda a: a[0][1]), key=lambda a: a[0][0]):
        
        f.write(str(item[0]) + ": " + str(item[1]) + ",\n")
        
    f.write("}")
In [ ]: