Skip to content

Commit 8e8cc77

Browse files
committed
initial commit
1 parent 3f09a1a commit 8e8cc77

7 files changed

Lines changed: 216 additions & 1 deletion

File tree

README.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,11 @@
1-
# data-tutorials
1+
# data-tutorials
2+
3+
Simple utility to download data from a url into a folder.
4+
It is a simple helper for cases when one needs to download data in systems like google colab to do a tutorial for example.
5+
6+
```python
7+
8+
from data import get_data
9+
get_data(url="", filename="LiFePO4_supercell.cif", folder="data")
10+
11+

data/LiFePO4_supercell.cif

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
# generated using pymatgen
2+
data_LiFePO4
3+
_symmetry_space_group_name_H-M 'P 1'
4+
_cell_length_a 10.23619605
5+
_cell_length_b 11.94151020
6+
_cell_length_c 9.30983438
7+
_cell_angle_alpha 90.0000
8+
_cell_angle_beta 90.00000000
9+
_cell_angle_gamma 90.00000000
10+
_symmetry_Int_Tables_number 1
11+
_chemical_formula_structural LiFePO4
12+
_chemical_formula_sum 'Li16 Fe16 P16 O64'
13+
_cell_volume 1137.99355945
14+
_cell_formula_units_Z 16
15+
loop_
16+
_symmetry_equiv_pos_site_id
17+
_symmetry_equiv_pos_as_xyz
18+
1 'x, y, z'
19+
loop_
20+
_atom_site_type_symbol
21+
_atom_site_label
22+
_atom_site_symmetry_multiplicity
23+
_atom_site_fract_x
24+
_atom_site_fract_y
25+
_atom_site_fract_z
26+
_atom_site_occupancy
27+
Li Li0 1 0.00000000 0.00000000 0.00000000 1
28+
Li Li1 1 0.00000000 0.00000000 0.50000000 1
29+
Li Li2 1 0.00000000 0.50000000 0.00000000 1
30+
Li Li3 1 0.00000000 0.50000000 0.50000000 1
31+
Li Li4 1 0.50000000 0.25000000 0.25000000 1
32+
Li Li5 1 0.50000000 0.25000000 0.75000000 1
33+
Li Li6 1 0.50000000 0.75000000 0.25000000 1
34+
Li Li7 1 0.50000000 0.75000000 0.75000000 1
35+
Li Li8 1 0.50000000 0.00000000 0.25000000 1
36+
Li Li9 1 0.50000000 0.00000000 0.75000000 1
37+
Li Li10 1 0.50000000 0.50000000 0.25000000 1
38+
Li Li11 1 0.50000000 0.50000000 0.75000000 1
39+
Li Li12 1 0.00000000 0.25000000 0.00000000 1
40+
Li Li13 1 0.00000000 0.25000000 0.50000000 1
41+
Li Li14 1 0.00000000 0.75000000 0.00000000 1
42+
Li Li15 1 0.00000000 0.75000000 0.50000000 1
43+
Fe Fe16 1 0.78115127 0.12500000 0.26493287 1
44+
Fe Fe17 1 0.78115127 0.12500000 0.76493287 1
45+
Fe Fe18 1 0.78115127 0.62500000 0.26493287 1
46+
Fe Fe19 1 0.78115127 0.62500000 0.76493287 1
47+
Fe Fe20 1 0.71884873 0.37500000 0.01493386 1
48+
Fe Fe21 1 0.71884873 0.37500000 0.51493386 1
49+
Fe Fe22 1 0.71884873 0.87500000 0.01493387 1
50+
Fe Fe23 1 0.71884873 0.87500000 0.51493386 1
51+
Fe Fe24 1 0.28115127 0.12500000 0.48506664 1
52+
Fe Fe25 1 0.28115127 0.12500000 0.98506664 1
53+
Fe Fe26 1 0.28115127 0.62500000 0.48506663 1
54+
Fe Fe27 1 0.28115127 0.62500000 0.98506664 1
55+
Fe Fe28 1 0.21884873 0.37500000 0.23506663 1
56+
Fe Fe29 1 0.21884873 0.37500000 0.73506664 1
57+
Fe Fe30 1 0.21884873 0.87500000 0.23506663 1
58+
Fe Fe31 1 0.21884873 0.87500000 0.73506664 1
59+
P P32 1 0.09386630 0.12500000 0.20931129 1
60+
P P33 1 0.09386630 0.12500000 0.70931128 1
61+
P P34 1 0.09386630 0.62500000 0.20931129 1
62+
P P35 1 0.09386630 0.62500000 0.70931128 1
63+
P P36 1 0.40613370 0.37500000 0.45931179 1
64+
P P37 1 0.40613370 0.37500000 0.95931179 1
65+
P P38 1 0.40613370 0.87500000 0.45931178 1
66+
P P39 1 0.40613370 0.87500000 0.95931179 1
67+
P P40 1 0.59386630 0.12500000 0.04068772 1
68+
P P41 1 0.59386630 0.12500000 0.54068772 1
69+
P P42 1 0.59386630 0.62500000 0.04068771 1
70+
P P43 1 0.59386630 0.62500000 0.54068772 1
71+
P P44 1 0.90613370 0.37500000 0.29068822 1
72+
P P45 1 0.90613370 0.37500000 0.79068822 1
73+
P P46 1 0.90613370 0.87500000 0.29068822 1
74+
P P47 1 0.90613370 0.87500000 0.79068821 1
75+
O O48 1 0.09423067 0.12500000 0.37239328 1
76+
O O49 1 0.09423067 0.12500000 0.87239328 1
77+
O O50 1 0.09423067 0.62500000 0.37239328 1
78+
O O51 1 0.09423067 0.62500000 0.87239328 1
79+
O O52 1 0.83415452 0.27277902 0.35686767 1
80+
O O53 1 0.83415452 0.27277902 0.85686767 1
81+
O O54 1 0.83415452 0.77277902 0.35686767 1
82+
O O55 1 0.83415452 0.77277902 0.85686767 1
83+
O O56 1 0.83415452 0.47722149 0.35686767 1
84+
O O57 1 0.83415452 0.47722149 0.85686767 1
85+
O O58 1 0.83415452 0.97722149 0.35686767 1
86+
O O59 1 0.83415452 0.97722149 0.85686767 1
87+
O O60 1 0.90577033 0.37500000 0.12760722 1
88+
O O61 1 0.90577033 0.37500000 0.62760722 1
89+
O O62 1 0.90577033 0.87500000 0.12760722 1
90+
O O63 1 0.90577033 0.87500000 0.62760722 1
91+
O O64 1 0.04430856 0.37500000 0.35493222 1
92+
O O65 1 0.04430856 0.37500000 0.85493222 1
93+
O O66 1 0.04430856 0.87500000 0.35493222 1
94+
O O67 1 0.04430856 0.87500000 0.85493222 1
95+
O O68 1 0.40576933 0.37500000 0.12239278 1
96+
O O69 1 0.40576933 0.37500000 0.62239278 1
97+
O O70 1 0.40576933 0.87500000 0.12239278 1
98+
O O71 1 0.40576933 0.87500000 0.62239278 1
99+
O O72 1 0.16584548 0.02277901 0.14313283 1
100+
O O73 1 0.16584548 0.02277902 0.64313283 1
101+
O O74 1 0.16584548 0.52277902 0.14313283 1
102+
O O75 1 0.16584548 0.52277902 0.64313283 1
103+
O O76 1 0.66584548 0.22722098 0.10686717 1
104+
O O77 1 0.66584548 0.22722098 0.60686717 1
105+
O O78 1 0.66584548 0.72722098 0.10686717 1
106+
O O79 1 0.66584548 0.72722098 0.60686717 1
107+
O O80 1 0.33415452 0.27277902 0.39313283 1
108+
O O81 1 0.33415452 0.27277902 0.89313283 1
109+
O O82 1 0.33415452 0.77277902 0.39313283 1
110+
O O83 1 0.33415452 0.77277902 0.89313283 1
111+
O O84 1 0.33415452 0.47722149 0.39313283 1
112+
O O85 1 0.33415452 0.47722149 0.89313283 1
113+
O O86 1 0.33415452 0.97722149 0.39313283 1
114+
O O87 1 0.33415452 0.97722149 0.89313283 1
115+
O O88 1 0.95569144 0.12500000 0.14506827 1
116+
O O89 1 0.95569144 0.12500000 0.64506827 1
117+
O O90 1 0.95569144 0.62500000 0.14506827 1
118+
O O91 1 0.95569144 0.62500000 0.64506828 1
119+
O O92 1 0.45569144 0.12500000 0.10493173 1
120+
O O93 1 0.45569144 0.12500000 0.60493173 1
121+
O O94 1 0.45569144 0.62500000 0.10493173 1
122+
O O95 1 0.45569144 0.62500000 0.60493173 1
123+
O O96 1 0.54430856 0.37500000 0.39506877 1
124+
O O97 1 0.54430856 0.37500000 0.89506878 1
125+
O O98 1 0.54430856 0.87500000 0.39506877 1
126+
O O99 1 0.54430856 0.87500000 0.89506878 1
127+
O O100 1 0.59423067 0.12500000 0.37760772 1
128+
O O101 1 0.59423067 0.12500000 0.87760772 1
129+
O O102 1 0.59423067 0.62500000 0.37760772 1
130+
O O103 1 0.59423067 0.62500000 0.87760772 1
131+
O O104 1 0.66584548 0.02277901 0.10686717 1
132+
O O105 1 0.66584548 0.02277901 0.60686717 1
133+
O O106 1 0.66584548 0.52277902 0.10686717 1
134+
O O107 1 0.66584548 0.52277902 0.60686717 1
135+
O O108 1 0.16584548 0.22722098 0.14313283 1
136+
O O109 1 0.16584548 0.22722099 0.64313283 1
137+
O O110 1 0.16584548 0.72722098 0.14313283 1
138+
O O111 1 0.16584548 0.72722098 0.64313283 1

data_tutorials/__init__.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
"""Tools to download files from a link
2+
3+
typical usage
4+
5+
>>> from data_tutorials.data import get_data
6+
>>> get_data(url="my_file_url", filename="mycif", folder="data")
7+
8+
9+
"""
10+
11+
from importlib.metadata import version
12+
13+
__version__ = version("data-tutorials")
467 Bytes
Binary file not shown.
1021 Bytes
Binary file not shown.

data_tutorials/data.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# -*- coding: utf-8 -*-
2+
# Author; alin m elena, alin@elena.re
3+
# Contribs;
4+
# Date: 26-07-2024
5+
# ©alin m elena, GPL v3 https://www.gnu.org/licenses/gpl-3.0.en.html
6+
7+
from urllib.request import urlretrieve
8+
from pathlib import Path
9+
10+
default_url = "https://raw.githubusercontent.com/imagdau/Tutorials/main/data/"
11+
12+
def get_data(url: str=default_url, filename: str| list[str] = "", folder: str="data") -> None:
13+
p = Path(folder)
14+
p.mkdir(parents=True, exist_ok=True)
15+
save_file = p/filename
16+
path, headers = urlretrieve(url+filename, save_file)
17+
if path.exists():
18+
print(f"saved in {save_file}")
19+
else:
20+
print(f"{save_file} could not be downloaded, check url.")

pyproject.toml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
[build-system]
2+
requires = ["setuptools >= 61.0"]
3+
build-backend = "setuptools.build_meta"
4+
5+
6+
[project]
7+
name = "data-tutorials"
8+
dynamic = ["version"]
9+
10+
requires-python = ">=3.9"
11+
authors = [
12+
{name = "Alin M Elena", email = "alin@elena.re"}
13+
]
14+
maintainers = [
15+
{name = "Alin M Elena", email = "alin@elena.re"}
16+
]
17+
description = "download data for tutorials"
18+
readme = "README.md"
19+
license = {file = "LICENSE"}
20+
keywords = ["data", "download"]
21+
classifiers = [
22+
"Development Status :: 4 - Beta",
23+
"Programming Language :: Python :: 3",
24+
"License :: OSI Approved :: MIT License",
25+
"Operating System :: OS Independent",
26+
]
27+
28+
[project.urls]
29+
Homepage = "https://github.com/ddmms/data-tutorials"
30+
Repository = "https://github.com/ddmms/data-tutorials.git"
31+
Issues = "https://github.com/ddmms/data-tutorials/issues"
32+
33+
[tool.setuptools]
34+
packages = ["data_tutorials"]

0 commit comments

Comments
 (0)