Esempio n. 1
0
def download_by_batch(batch_num):
    t1 = time.time()
    with qr.QMPYRester() as q:
        kwargs = {
            'limit': PAGE_LIMIT,
            'offset': batch_num * PAGE_LIMIT,
            'element_set': 'He',
            'icsd': 'T',
            'fields': 'entry_id,icsd_id,unit_cell,sites',
        }
        data = q.get_oqmd_phases(verbose=False, **kwargs)
    t2 = time.time()

    if batch_num == 0:
        print('Size of query dataset is %d.' % data['count'])

    with open('query_files/query_' + str(batch_num) + '.json',
              'w') as json_file:
        json.dump(data['results'], json_file, indent=2)

    print('Loading Batch %d time %.3f seconds' % (batch_num, t2 - t1))

    if data['next']:
        return True
    else:
        return False
Esempio n. 2
0
 def test_rester_optimade_by_id_output(self):
     with qr.QMPYRester() as q:
         data = q.get_optimade_structure_by_id(id=4061139,
                                               fields='id,chemical_formula')
     self.assertEqual(data, {
         'id': 4061139,
         'chemical_formula': 'Cs1Ho1S4Si1'
     })
Esempio n. 3
0
def download_by_batch(batch_num):
    t1 = time.time()
    with qr.QMPYRester() as q:
        kwargs = {'limit':PAGE_LIMIT, 
                  'offset': batch_num*PAGE_LIMIT,
                  'elements': 'He',
                  'fields':'_oqmd_entry_id,_oqmd_unit_cell,_oqmd_sites',
                  }
        data = q.get_optimade_structures(verbose=False, **kwargs)
    t2 = time.time()

    if batch_num == 0:
        print('Size of query dataset is %d.'%data['meta']['data_available'])
    
    with open('query_files/query_'+str(batch_num)+'.json', 'w') as json_file:
        json.dump(data['data'], json_file, indent=2)
    
    print('Loading Batch %d time %.3f seconds'%(batch_num, t2-t1))

    if data['links']['next']:
        return True
    else:
        return False
Esempio n. 4
0
 def test_rester_oqmdapi_output_dict(self):
     with qr.QMPYRester() as q:
         kwargs = {'limit': '1'}
         data = q.get_oqmd_phases(verbose=False, **kwargs)
     self.assertTrue(isinstance(data, dict))
Esempio n. 5
0
 def test_rester_oqmdapi_by_id_output(self):
     with qr.QMPYRester() as q:
         data = q.get_oqmd_phase_by_id(fe_id=4061139, fields='name')
     self.assertEqual(data, {'name': 'CsHoSiS4'})
Esempio n. 6
0
 def test_rester_oqmdapi_phase_space_output_dict(self):
     with qr.QMPYRester() as q:
         data = q.get_oqmd_phase_space('Pd-O')
     self.assertTrue(isinstance(data, dict))