Skip to content

Commit 7b3a2cb

Browse files
database: Made record id flexible
1 parent c63801c commit 7b3a2cb

File tree

2 files changed

+55
-3
lines changed

2 files changed

+55
-3
lines changed

opxrd/database/opxrd.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
from xrdpattern.pattern import PatternDB
77
from holytools.userIO import TrackedInt
88

9+
# -----------------------------
10+
911

1012
class OpXRD(PatternDB):
1113
@classmethod
@@ -22,9 +24,9 @@ def load(cls, root_dirpath : str, download : bool = True, *args, **kwargs) -> Pa
2224
print(f'- Loading patterns from local files')
2325
return super().load(dirpath=root_dirpath, strict=True)
2426

25-
@staticmethod
26-
def _download_zenodo_opxrd(output_fpath : str):
27-
zenodo_url = f'https://zenodo.org/records/14278656'
27+
@classmethod
28+
def _download_zenodo_opxrd(cls, output_fpath : str):
29+
zenodo_url = f'https://zenodo.org/records/{cls.get_record_id()}'
2830
file_response = requests.get(url=f'{zenodo_url}/files/opxrd.zip?download=1', stream=True)
2931

3032
total_size = int(file_response.headers.get('content-length', 0))
@@ -48,6 +50,9 @@ def _unzip_file(zip_fpath : str, output_dir : str):
4850
zip_ref.extractall(output_dir)
4951
return f"Files extracted to {output_dir}"
5052

53+
@classmethod
54+
def get_record_id(cls) -> int:
55+
return 14279434
5156

5257
if __name__ == "__main__":
5358
opxrd = OpXRD.load(root_dirpath='../data/opxrd')

opxrd/usage.ipynb

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,53 @@
4949
"sys.stdout = stdout"
5050
]
5151
},
52+
{
53+
"cell_type": "code",
54+
"outputs": [
55+
{
56+
"name": "stdout",
57+
"output_type": "stream",
58+
"text": [
59+
"- Loading patterns from local files\n"
60+
]
61+
},
62+
{
63+
"name": "stderr",
64+
"output_type": "stream",
65+
"text": [
66+
"\u001B[38;2;0;255;0m100%\u001B[39m \u001B[38;2;0;255;0m(84197 of 84197)\u001B[39m |##################| Elapsed Time: 0:02:16 Time: 0:02:160110\n"
67+
]
68+
}
69+
],
70+
"source": [
71+
"from opxrd import OpXRD\n",
72+
"\n",
73+
"opxrd = OpXRD.load(root_dirpath='/home/daniel/aimat/data/opXRD/final/')"
74+
],
75+
"metadata": {
76+
"collapsed": false,
77+
"ExecuteTime": {
78+
"end_time": "2024-12-05T01:53:25.119145Z",
79+
"start_time": "2024-12-05T01:51:03.405227Z"
80+
}
81+
},
82+
"id": "ca2689f7b9f7dbe3",
83+
"execution_count": 1
84+
},
85+
{
86+
"cell_type": "code",
87+
"outputs": [],
88+
"source": [
89+
"opxrd.plot_quantity(attr='primary_phase.spaecgroup')\n",
90+
"opxrd.plot_quantity(attr='startval')\n",
91+
"opxrd.plot_quantity(attr='endval')\n",
92+
"opxrd.plot_quantity()"
93+
],
94+
"metadata": {
95+
"collapsed": false
96+
},
97+
"id": "ab9c2dc1b83bbc9c"
98+
},
5299
{
53100
"cell_type": "code",
54101
"execution_count": 3,

0 commit comments

Comments
 (0)