Good evening,
I’m having trouble understanding how to download specific raw files using the python API.
I’m aware of the previous threads on this topic:
- Download/save specific raw files from NOMAD? : this one seems to refer to a previous version of NOMAD (correct?), and anyway doesn’t explain how to actually get the files through python
- Download ABINIT input files from NOMAD : this one doesn’t explain how to get the files through the python API.
Now, I did manage to download the entire, zipped, raw directory (example1 below) and get the path where the specific file I’m looking for is (example2 below). What I’m missing is how to combine the two things, i.e. how to get a specific raw file through the python api without downloading the whole zipped folder. The naive attempt I made (example3) does not work (404, file not found).
Many Thanks,
Gabriele
+++example1++++++++++++++++++++++++++++++++++
base_url = ‘NOMAD API - Swagger UI’
for mat in response_json[‘data’]: #response from query on {base_url}/entries/query
string=base_url+“/entries/”+mat[‘entry_id’]+“/raw?compress=True”
resp2=requests.get(string,stream=True)
filename=mat[‘entry_id’][3:-1]+“.zip”
open(filename,“wb”).write(resp2.content)
+++++++++++++++++++++++++++++++++++++++++
+++example2+++++++++++++++++++++++++++++++
base_url = ‘NOMAD API - Swagger UI’
for mat in response_json[‘data’]: #response from query on {base_url}/entries/rawdir/query
for ff in mat[‘files’]:
print(ff[‘path’])
++++++++++++++++++++++++++++++++++++++++++
+++example3+++++++++++++++++++++++++++++++++
base_url = ‘NOMAD API - Swagger UI’
for mat in response_json[‘data’]:
for fil in mat[‘files’]:
if “CONTCAR” in fil[‘path’]: #resp. from {base_url}/entries/rawdir/query with “program_name’:‘VASP’”
#string=base_url+“/entries/”+mat[‘entry_id’]+‘/’+fil[‘path’] #this doesnt work, too
string=base_url+“/entries/”+fil[‘path’]
resp2=requests.get(string,stream=True)
filename=mat[‘entry_id’][3:-1]+“.vasp”
open(filename,“wb”).write(resp2.content)
++++++++++++++++++++++++++++++++++++++++++++