Example #1
0
def iiif_info_url(msid, filename):
    kwargs = {
        'padded-msid': utils.pad_msid(msid),
        'fname': filename
    }
    raw_link = (conf.IIIF % kwargs)
    return utils.pad_filename(msid, raw_link)
Example #2
0
 def test_expand_image(self):
     msid = 1234
     given = [
         {
             "type": "video",
             "image": "https://foo.bar/baz.bup"
         },
         {
             "type": "image",
             "image": {
                 "uri": "https://foo.bar/baz.bup"
             }
         },
     ]
     expected = [
         {
             "type": "video",
             "image": utils.pad_filename(msid,
                                         main.cdnlink(msid, "baz.bup"))
         },
         main.expand_iiif_uri(msid, {
             "type": "image",
             "image": {
                 "uri": "https://foo.bar/baz.bup"
             }
         }, "image"),
     ]
     self.assertEqual(main.expand_image(msid, given), expected)
Example #3
0
 def fn(element):
     if element.get("type") == "video":
         element["image"] = cdnlink(msid, element["image"].split('/')[-1])
         element["image"] = utils.pad_filename(msid, element["image"])
     else:
         if isinstance(element.get("image"), dict) and element.get("image").get("uri"):
             element = expand_iiif_uri(msid, element, "image")
     return element
Example #4
0
 def fn(element):
     if element.get("type") == "video":
         element["image"] = cdnlink(msid, element["image"].split('/')[-1])
         element["image"] = utils.pad_filename(msid, element["image"])
     else:
         if isinstance(element.get("image"),
                       dict) and element.get("image").get("uri"):
             element = expand_iiif_uri(msid, element, "image")
     return element
Example #5
0
 def test_pad_filename(self):
     cases = [
         ((1234, "https://foo.bar/baz.bup"), "https://foo.bar/baz.bup"),
         ((10001234,
           "https://publishing-cdn.elifesciences.org/01234/elife-01234-v1.pdf"
           ),
          "https://publishing-cdn.elifesciences.org/01234/elife-10001234-v1.pdf"
          ),
     ]
     for (msid, filename), expected in cases:
         self.assertEqual(utils.pad_filename(msid, filename), expected)
Example #6
0
# Reading in the hdf5 data

data = h5py.File(file_hdf5, "r")

xyz = np.array(data.get("xyz"))
zs = np.array(data.get("zs"), dtype=np.int32)
traj_idx = np.array(data.get("traj_idx"), dtype=np.int32)

# Generating a new molpro directory
os.mkdir(molpro_dir_name)

# The Molpro input file header and footer
n_electrons = np.sum(zs[0])
header = "memory,500,m\ngeomtyp=xyz\nnosym\nnoorient\ngdirect\ngeometry={\n"
footer = "}\nbasis={ default,tzvp }\n{uks,b3lyp,direct;wf,%s,1,1}\nforce\n{ibba,bonds=1}" % str(
    n_electrons)

# The loop to create each input file
n_files = xyz.shape[0]
for n in range(n_files):

    filenumber = utils.pad_filename(n)
    file_name = filenumber + "_" + str(traj_idx[n]) + "_ccsd.com"

    utils.write_molpro_input(xyz[n], zs[n], file_name, molpro_dir_name, header,
                             footer)

    if n == 5:
        exit()
Example #7
0
def iiiflink(msid, filename):
    kwargs = {'padded-msid': utils.pad_msid(msid), 'fname': filename}
    raw_link = (conf.CDN_IIIF % kwargs)
    return utils.pad_filename(msid, raw_link)