cmipcite.citations#
Citation support
Classes:
| Name | Description |
|---|---|
AuthorListStyle |
Author list style |
DOIGranularity |
DOI granularity |
FormatOption |
Citation format options |
Functions:
| Name | Description |
|---|---|
get |
Get citations without duplicates from CMIP files or tracking IDs or PIDs |
get_bibtex_citation |
Get bibtex citation |
get_citations |
Get citations that apply to the given IDs or paths |
get_doi_and_version |
Get DOI and version for a given ID or path to a netCDF file |
get_text_citation |
Get text citation |
get_tracking_id_from_cmip_netcdf |
Get tracking ID from a CMIP netCDF file |
translate_get_args_to_get_citations_kwargs |
Translate the arguments of (m).get to arguments needed by (m).get_citations |
AuthorListStyle #
DOIGranularity #
Bases: StrEnum
DOI granularity
CMIP data can be aggregated at different granularities.
Data citations are designated on data aggregations belonging to a model
contribution to a MIP (or activity_id) and on data belonging to an experiment
contributed by a specific model:
model:
Attributes:
| Name | Type | Description |
|---|---|---|
EXPERIMENT |
mip-model-experiment granularity of DOI. |
|
MODEL |
mip-model granularity of DOI. |
Source code in src/cmipcite/citations.py
FormatOption #
get #
get(
in_values: list[str],
format: FormatOption = TEXT,
author_list_style: AuthorListStyle = LONG,
doi_granularity: DOIGranularity = MODEL,
multi_dataset_handling: MultiDatasetHandlingStrategy
| None = None,
handle_server_url: str = "http://hdl.handle.net/",
) -> list[str]
Get citations without duplicates from CMIP files or tracking IDs or PIDs
This function mirrors the CLI get command as closely as possible.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
in_values
|
list[str]
|
Tracking IDs, PIDs or file paths for which to generate citations.
Paths should point to a CMIP file with a |
required |
format
|
FormatOption
|
Format in which to retrieve the citations |
TEXT
|
author_list_style
|
AuthorListStyle
|
Whether, if the format is text, the author list should be long (all names) or short (et al.) |
LONG
|
doi_granularity
|
DOIGranularity
|
Granularity of DOI to retrieve. See DOIGranularity for details. |
MODEL
|
multi_dataset_handling
|
MultiDatasetHandlingStrategy | None
|
Strategy to use when a given ID or file belongs to multiple datasets |
None
|
handle_server_url
|
str
|
URL of the server to use for handling tracking IDs i.e. handles If not supplied, a new client with a default handle server URL is instantiated. |
'http://hdl.handle.net/'
|
Returns:
| Type | Description |
|---|---|
list[str]
|
Retrieved citations for |
Notes
Citations can be retrieved with the help of the Persistent IDentifiers (PIDs). In the CMIP world, there are two types of PIDs:
- file PID (normally referred to as a tracking ID)
- dataset PID (normally simply referred to as PID).
A dataset is a collection of files
(for CMIP, this collection of files
is for a single variable sampled at a single frequency and spatial sampling
from a single model running a single experiment).
Both PID types can be passed to in_values.
For a given PID, we can retrieve an associated DOI.
However, there are multiple possibilities for the retrieved DOI.
These vary based on the granularity of the DOI.
At the moment, as far as we know, there are two granularities:
* model (capturing all submissions to a given MIP by a given model)
* experiment (capturing all submissions to a given MIP by a given model for a
given experiment.
This is controlled by doi_granularity.
Source code in src/cmipcite/citations.py
465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 | |
get_bibtex_citation #
Get bibtex citation
The version is added to the title field.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
doi
|
str
|
DOI for which to get the citation |
required |
version
|
str
|
Version of the dataset associated with |
required |
Returns:
| Type | Description |
|---|---|
str
|
Bibtex citation |
Source code in src/cmipcite/citations.py
get_citations #
get_citations(
ids_or_paths: list[str],
get_citation: Callable[[str, str], str],
doi_granularity: DOIGranularity,
client: RESTHandleClient | None = None,
multi_dataset_handling: MultiDatasetHandlingStrategy
| None = None,
) -> list[str]
Get citations that apply to the given IDs or paths
If your IDs are tracking IDs or paths, then two or more IDs/paths can share the same citation. This function returns the minimum set of citations required i.e. any duplicate citations are removed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ids_or_paths
|
list[str]
|
Tracking ids (file PID), dataset PIDs and paths for which to get citations. Tracking ids identify files.
To date, they can be found
in the PIDs identify datasets (a group of files). Paths should point to a CMIP file with a |
required |
get_citation
|
Callable[[str, str], str]
|
Function which, given a DOI and a version, produces a citation For example, get_bibtex_citation. |
required |
doi_granularity
|
DOIGranularity
|
Granularity of DOI to retrieve. See DOIGranularity for details. |
required |
client
|
RESTHandleClient | None
|
Client to use for interacting with pyhandle's REST API If not supplied, a new client with a default handle server URL is instantiated. |
None
|
multi_dataset_handling
|
MultiDatasetHandlingStrategy | None
|
What to do in the case that the tracking ID belongs to multiple datasets i.e. is associated with more than one PID. Passed to get_dataset_pid. |
None
|
Returns:
| Type | Description |
|---|---|
list[str]
|
Citations for the given |
Notes
Citations can be retrieved with the help of the Persistent IDentifiers (PIDs). In the CMIP world, there are two types of PIDs:
- file PID (normally referred to as a tracking ID)
- dataset PID (normally simply referred to as PID).
A dataset is a collection of files
(for CMIP, this collection of files
is for a single variable sampled at a single frequency and spatial sampling
from a single model running a single experiment).
Both PID types can be passed to ids_or_paths.
For a given PID, we can retrieve an associated DOI.
However, there are multiple possibilities for the retrieved DOI.
These vary based on the granularity of the DOI.
At the moment, as far as we know, there are two granularities:
* model (capturing all submissions to a given MIP by a given model)
* experiment (capturing all submissions to a given MIP by a given model for a
given experiment.
This is controlled by doi_granularity.
Examples:
>>> citations = get_citations(
... ["hdl:21.14100/f2f502c9-9626-31c6-b016-3f7c0534803b"],
... doi_granularity=DOIGranularity.MODEL,
... get_citation=get_bibtex_citation,
... )
>>> print(citations[0])
@misc{https://doi.org/10.22033/esgf/cmip6.742,
doi = {10.22033/ESGF/CMIP6.742},
url = {http://cera-www.dkrz.de/WDCC/meta/CMIP6/CMIP6.CMIP.MPI-M.MPI-ESM1-2-LR},
author = {Wieners, Karl-Hermann and Giorgetta, Marco and Jungclaus, Johann and Reick, Christian and Esch, Monika and Bittner, Matthias and Legutke, Stephanie and Schupfner, Martin and Wachsmann, Fabian and Gayler, Veronika and Haak, Helmuth and de Vrese, Philipp and Raddatz, Thomas and Mauritsen, Thorsten and von Storch, Jin-Song and Behrens, Jörg and Brovkin, Victor and Claussen, Martin and Crueger, Traute and Fast, Irina and Fiedler, Stephanie and Hagemann, Stefan and Hohenegger, Cathy and Jahns, Thomas and Kloster, Silvia and Kinne, Stefan and Lasslop, Gitta and Kornblueh, Luis and Marotzke, Jochem and Matei, Daniela and Meraner, Katharina and Mikolajewicz, Uwe and Modali, Kameswarrao and Müller, Wolfgang and Nabel, Julia and Notz, Dirk and Peters-von Gehlen, Karsten and Pincus, Robert and Pohlmann, Holger and Pongratz, Julia and Rast, Sebastian and Schmidt, Hauke and Schnur, Reiner and Schulzweida, Uwe and Six, Katharina and Stevens, Bjorn and Voigt, Aiko and Roeckner, Erich},
keywords = {CMIP6, climate, CMIP6.CMIP.MPI-M.MPI-ESM1-2-LR},
language = {en},
title = {MPI-M MPIESM1.2-LR model output prepared for CMIP6 CMIP. Version 20211412.},
publisher = {Earth System Grid Federation},
year = {2019},
copyright = {Creative Commons Attribution 4.0 International}
}
Source code in src/cmipcite/citations.py
298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 | |
get_doi_and_version #
get_doi_and_version(
in_value: str,
doi_granularity: DOIGranularity,
client: RESTHandleClient | None = None,
get_tracking_id_from_path: Callable[
[Path], str
] = get_tracking_id_from_cmip_netcdf,
multi_dataset_handling: MultiDatasetHandlingStrategy
| None = None,
) -> tuple[str, str]
Get DOI and version for a given ID or path to a netCDF file
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
in_value
|
str
|
Input ID or path to a netCDF file |
required |
doi_granularity
|
DOIGranularity
|
Granularity of DOI to retrieve. We use the 'lowest-level' from the DRS as a short-hand. "experiment" is short for mip-model-experiment. "model" is short for mip-model. See DOIGranularity for details. |
required |
client
|
RESTHandleClient | None
|
Client to use for interacting with pyhandle's REST API If not supplied, a new client with a default handle server URL is instantiated. |
None
|
get_tracking_id_from_path
|
Callable[[Path], str]
|
Function which, given a path outputs the tracking ID |
get_tracking_id_from_cmip_netcdf
|
multi_dataset_handling
|
MultiDatasetHandlingStrategy | None
|
What to do in the case that the tracking ID belongs to multiple datasets i.e. is associated with more than one PID. Passed to get_dataset_pid. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
doi |
str
|
DOI that applies to |
version |
str
|
Version that applies to |
Source code in src/cmipcite/citations.py
194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 | |
get_text_citation #
get_text_citation(
doi: str,
version: str,
author_list_style: AuthorListStyle,
) -> str
Get text citation
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
doi
|
str
|
DOI for which to get the citation |
required |
version
|
str
|
Version of the dataset associated with |
required |
author_list_style
|
AuthorListStyle
|
Style to use for the author list |
required |
Returns:
| Type | Description |
|---|---|
str
|
Plain text citation |
Source code in src/cmipcite/citations.py
get_tracking_id_from_cmip_netcdf #
Get tracking ID from a CMIP netCDF file
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
nc_path
|
Path
|
Path to the CMIP netCDF file. The file must have a |
required |
Returns:
| Type | Description |
|---|---|
str
|
Tracking ID |
Source code in src/cmipcite/citations.py
translate_get_args_to_get_citations_kwargs #
translate_get_args_to_get_citations_kwargs(
format: FormatOption,
author_list_style: AuthorListStyle,
handle_server_url: str = "http://hdl.handle.net/",
) -> dict[str, Any]
Translate the arguments of (m).get to arguments needed by (m).get_citations
(m).get_citations is a lower-level function that supports dependency injection. (m).get is meant to mirror the equivalent command-line interface command, therefore has to work with more primitive types and does not support (direct) dependency injection.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
format
|
FormatOption
|
Format in which to retrieve the citations |
required |
author_list_style
|
AuthorListStyle
|
Whether, if the format is text, the author list should be long (all names) or short (et al.) |
required |
handle_server_url
|
str
|
URL of the server to use for handling tracking IDs i.e. handles |
'http://hdl.handle.net/'
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Keyword arguments which can be passed to (m).get_citations |