Skip to content

Commit

Permalink
Split url attribute into data_url and data_url_history
Browse files Browse the repository at this point in the history
  • Loading branch information
nollety committed Jan 13, 2023
1 parent 42c53e8 commit 955d6d0
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 21 deletions.
5 changes: 2 additions & 3 deletions notebooks/coddington_2021.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -188,10 +188,9 @@
" \"title\": f\"{TITLE} ({resolution})\",\n",
" \"institution\": INSTITUTION,\n",
" \"source\": SOURCE,\n",
" \"reference\": REFERENCES,\n",
" \"raw_data_url\": RAW_DATA_URL\n",
" \"references\": REFERENCES,\n",
" }\n",
" ds = tengen.to_dataset(ssi=ssi, w=w, url=RAW_DATA_URL, attrs=_attrs)\n",
" ds = tengen.to_dataset(ssi=ssi, w=w, data_url=RAW_DATA_URL, attrs=_attrs)\n",
"\n",
" if path is not None:\n",
" resolution = f\"{res:~}\".replace(\" \", \"_\")\n",
Expand Down
5 changes: 2 additions & 3 deletions notebooks/coddington_2022.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -192,10 +192,9 @@
" \"title\": f\"{TITLE} ({resolution})\",\n",
" \"institution\": INSTITUTION,\n",
" \"source\": SOURCE,\n",
" \"reference\": REFERENCES,\n",
" \"raw_data_url\": RAW_DATA_URL\n",
" \"references\": REFERENCES,\n",
" }\n",
" ds = tengen.to_dataset(ssi=ssi, w=w, url=RAW_DATA_URL, attrs=_attrs)\n",
" ds = tengen.to_dataset(ssi=ssi, w=w, data_url=RAW_DATA_URL, attrs=_attrs)\n",
"\n",
" if path is not None:\n",
" resolution = f\"{res:~}\".replace(\" \", \"_\")\n",
Expand Down
6 changes: 3 additions & 3 deletions notebooks/meftah_2018.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -142,12 +142,12 @@
" end = datetime.date(2016, 12, 31)\n",
" observation_period=\" to \".join(\n",
" [x.strftime(\"%Y-%m-%d\") for x in [start, end]]\n",
" ),\n",
" )\n",
"\n",
" ds = tengen.to_dataset(\n",
" ssi=ssi,\n",
" w=w,\n",
" url=RAW_DATA_URL,\n",
" data_url=RAW_DATA_URL,\n",
" attrs={\n",
" \"title\": TITLE,\n",
" \"institution\": INSTITUTION,\n",
Expand Down Expand Up @@ -200,7 +200,7 @@
" url=RAW_DATA_URL,\n",
" path=tmpdir,\n",
" )\n",
" datasets = format_raw_data(\n",
" dataset = format_raw_data(\n",
" raw_data=tmpdir,\n",
" path=None,\n",
" )"
Expand Down
4 changes: 2 additions & 2 deletions notebooks/solid_2017.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@
" ds = tengen.to_dataset(\n",
" w=w,\n",
" ssi=ssi,\n",
" url=RAW_DATA_URL,\n",
" data_url=RAW_DATA_URL,\n",
" t=t,\n",
" attrs={\n",
" \"title\": TITLE,\n",
Expand Down Expand Up @@ -238,7 +238,7 @@
" url=RAW_DATA_URL,\n",
" path=tmpdir,\n",
" )\n",
" datasets = format_raw_data(\n",
" dataset = format_raw_data(\n",
" raw_data=tmpdir,\n",
" path=None,\n",
" )"
Expand Down
2 changes: 1 addition & 1 deletion notebooks/template.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@
" url=RAW_DATA_URL,\n",
" path=tmpdir,\n",
" )\n",
" datasets = format_raw_data(\n",
" dataset = format_raw_data(\n",
" raw_data=tmpdir,\n",
" path=None,\n",
" )"
Expand Down
4 changes: 2 additions & 2 deletions notebooks/thuillier_2003.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@
" ds = tengen.to_dataset(\n",
" w=w,\n",
" ssi=ssi,\n",
" url=RAW_DATA_URL,\n",
" data_url=RAW_DATA_URL,\n",
" attrs={\n",
" \"Conventions\": \"CF-1.10\",\n",
" \"title\": TITLE,\n",
Expand Down Expand Up @@ -180,7 +180,7 @@
" url=RAW_DATA_URL,\n",
" path=tmpdir,\n",
" )\n",
" datasets = format_raw_data(\n",
" dataset = format_raw_data(\n",
" raw_data=tmpdir,\n",
" path=None,\n",
" )"
Expand Down
2 changes: 1 addition & 1 deletion notebooks/whi_2008.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@
" dataset = tengen.to_dataset(\n",
" ssi=data[:, time_period_index] * ureg.W / ureg.m ** 2 / ureg.nm,\n",
" w=wavelength * ureg.nm,\n",
" url=RAW_DATA_URL,\n",
" data_url=RAW_DATA_URL,\n",
" attrs={\n",
" \"title\": TITLE + f\" ({identifier})\",\n",
" \"institution\": INSTITUTION,\n",
Expand Down
13 changes: 7 additions & 6 deletions src/tengen/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
def to_dataset(
ssi: pint.Quantity,
w: pint.Quantity,
url: str,
data_url: str,
t: t.Optional[pd.DatetimeIndex] = None,
attrs: t.Optional[t.Dict[str, str]] = None,
) -> xr.Dataset:
Expand All @@ -40,7 +40,7 @@ def to_dataset(
Args:
ssi: solar spectral irradiance.
w: radiation wavelength.
url: raw data url.
data_url: raw data url.
t: time stamps.
attrs: dataset attributes.
Expand Down Expand Up @@ -77,10 +77,11 @@ def to_dataset(

author = f"tengen, version {__version__}"
_attrs.update(
dict(
history=f"{utcnow} - data set creation by {author}",
url=f"raw data available at {url} (last accessed on {utcnow})",
)
{
"history": f"{utcnow} - data set creation by {author}",
"data_url": data_url,
"data_url_datetime": utcnow,
}
)

# Create data set
Expand Down

0 comments on commit 955d6d0

Please sign in to comment.