Groundwater chemistry#

Water quality analyses from SGU’s Grundvattenkvalitet, analysresultat och provplatser (version 2) API, available as client.chemistry. See Groundwater chemistry for a walkthrough.

Methods#

get_sampling_sites

Get groundwater chemistry sampling sites.

get_sampling_site

Get a specific groundwater chemistry sampling site by ID.

get_sampling_site_by_name

Convenience function to get a sampling site by any site identifier.

get_sampling_sites_by_names

Convenience function to get multiple sampling sites by any site identifier.

get_analysis_results

Get groundwater chemistry analysis results.

get_analysis_result

Get a specific groundwater chemistry analysis result by ID.

get_results_by_site

Get analysis results for a specific site with optional time filtering.

get_results_by_sites

Get analysis results for multiple sites with optional time filtering.

get_results_by_parameter

Get analysis results filtered by chemical parameter (e.g., pH, nitrate).

Models#

SamplingSiteCollection

Collection of groundwater chemistry sampling sites (GeoJSON FeatureCollection).

SamplingSite

A groundwater chemistry sampling site (GeoJSON Feature).

SamplingSiteProperties

Properties for a groundwater chemistry sampling site.

AnalysisResultCollection

Collection of groundwater chemistry analysis results (GeoJSON FeatureCollection).

AnalysisResult

A groundwater chemistry analysis result (GeoJSON Feature).

AnalysisResultProperties

Properties for a groundwater chemistry analysis result.

Client#

class GroundwaterChemistryClient(base_client)[source]#

Client for groundwater chemistry-related SGU API endpoints.

get_sampling_sites(bbox=None, datetime=None, limit=None, filter_expr=None, sortby=None, **kwargs)[source]#

Get groundwater chemistry sampling sites.

This method is used internally by convenience functions like get_sampling_site_by_name() by constructing filter expressions. A user may also do this, but readability is greater when using the built-in convenience functions.

Parameters:
  • bbox (list[float] | None) – Bounding box as [min_lon, min_lat, max_lon, max_lat]

  • datetime (str | None) – Date/time filter (RFC 3339 format or interval)

  • limit (int | None) – Maximum number of features to return (paginated automatically)

  • filter_expr (str | None) – CQL filter expression

  • sortby (list[str] | None) – List of sort expressions (e.g., [‘+name’, ‘-date’]) Note: the SGU v2 chemistry API currently ignores sortby; features are returned in the server’s default order.

  • **kwargs (Any) – Additional query parameters

Return type:

SamplingSiteCollection

Returns:

Typed collection of groundwater chemistry sampling sites

get_sampling_site(site_id)[source]#

Get a specific groundwater chemistry sampling site by ID.

This endpoint is provided by the OGC API but likely not used by any user.

Parameters:

site_id (str) – Site identifier

Return type:

SamplingSite

Returns:

Typed groundwater chemistry sampling site

Raises:

ValueError – If site not found or multiple sites returned

get_sampling_site_by_name(site_id=None, site_name=None, national_site_id=None, **kwargs)[source]#

Convenience function to get a sampling site by any site identifier.

Parameters:
  • site_id (str | None) – Site identifier (maps to ‘platsbeteckning’ in API)

  • site_name (str | None) – Site name (maps to ‘provplatsnamn’ in API)

  • national_site_id (int | None) – National sampling site ID (maps to ‘nationellt_provplatsid’ in API)

  • **kwargs (Any) – Additional query parameters (e.g., limit)

Return type:

SamplingSite

Returns:

Typed groundwater chemistry sampling site

Raises:

Example

>>> from sgu_client import SGUClient
>>> with SGUClient() as client:
...     # find site by id
...     site = client.chemistry.get_sampling_site_by_name(site_id="TTK-442-M")
...     # find site by name
...     site = client.chemistry.get_sampling_site_by_name(site_name="Lena")
...     # find site by national site id
...     site = client.chemistry.get_sampling_site_by_name(
...         national_site_id=359366
...     )
...     print(site.properties.municipality)
get_sampling_sites_by_names(site_id=None, site_name=None, national_site_id=None, **kwargs)[source]#

Convenience function to get multiple sampling sites by any site identifier.

Parameters:
  • site_id (list[str] | None) – List of site identifiers (maps to ‘platsbeteckning’ in API)

  • site_name (list[str] | None) – List of site names (maps to ‘provplatsnamn’ in API)

  • national_site_id (list[int] | None) – List of national sampling site IDs (maps to ‘nationellt_provplatsid’ in API)

  • **kwargs (Any) – Additional query parameters (e.g., limit)

Return type:

SamplingSiteCollection

Returns:

Typed collection of groundwater chemistry sampling sites

Raises:

Example

>>> from sgu_client import SGUClient
>>> with SGUClient() as client:
...     # get multiple sampling sites by their IDs
...     sites = client.chemistry.get_sampling_sites_by_names(
...         site_id=["TTK-442-M", "SYD-681-C"]
...     )
...     for site in sites.features:
...         props = site.properties
...         print(f"{props.station_id}: {props.national_site_id}")
get_analysis_results(bbox=None, datetime=None, limit=None, filter_expr=None, sortby=None, tmin=None, tmax=None, **kwargs)[source]#

Get groundwater chemistry analysis results.

This method is used internally by convenience functions like get_results_by_site() by constructing filter expressions. A user may also do this, but readability is greater when using the built-in convenience functions.

Parameters:
  • bbox (list[float] | None) – Bounding box as [min_lon, min_lat, max_lon, max_lat]

  • datetime (str | None) – Raw OGC date/time filter; prefer tmin/tmax

  • limit (int | None) – Maximum number of features to return (paginated automatically)

  • filter_expr (str | None) – CQL filter expression

  • sortby (list[str] | None) – List of sort expressions (e.g., [‘+date’, ‘-value’]) Note: the SGU v2 chemistry API currently ignores sortby; features are returned in the server’s default order.

  • tmin (str | datetime | None) – Earliest sampling date (ISO string or datetime object)

  • tmax (str | datetime | None) – Latest sampling date (ISO string or datetime object)

  • **kwargs (Any) – Additional query parameters

Return type:

AnalysisResultCollection

Returns:

Typed collection of groundwater chemistry analysis results

get_analysis_result(result_id)[source]#

Get a specific groundwater chemistry analysis result by ID.

This endpoint is provided by the OGC API but likely not used by any user.

Parameters:

result_id (str) – Result identifier

Return type:

AnalysisResult

Returns:

Typed groundwater chemistry analysis result

Raises:

ValueError – If result not found or multiple results returned

get_results_by_site(national_site_id=None, site_id=None, site_name=None, tmin=None, tmax=None, limit=None, **kwargs)[source]#

Get analysis results for a specific site with optional time filtering.

Analysis results are linked to sampling sites by national_site_id, which is the recommended (and fastest) way to identify a site. Using site_id or site_name requires an additional API request to look up the site.

Parameters:
  • national_site_id (int | None) – National sampling site ID (maps to ‘nationellt_provplatsid’ in API)

  • site_id (str | None) – Site identifier (maps to ‘platsbeteckning’ in API)

  • site_name (str | None) – Site name (maps to ‘provplatsnamn’ in API)

  • tmin (str | datetime | None) – Start time (ISO string or datetime object)

  • tmax (str | datetime | None) – End time (ISO string or datetime object)

  • limit (int | None) – Maximum number of results to return

  • **kwargs (Any) – Additional query parameters

Return type:

AnalysisResultCollection

Returns:

Typed collection of groundwater chemistry analysis results

Raises:
  • SGUNotFoundError – If a site_id or site_name matches no site.

  • SGUAmbiguousError – If a site_id or site_name matches several sites.

  • ValueError – If not exactly one of national_site_id, site_id or site_name is provided, or if the looked-up site has no national_site_id.

Example

>>> from sgu_client import SGUClient
>>> from datetime import datetime, timezone
>>> with SGUClient() as client:
...     # get all results for a site
...     results = client.chemistry.get_results_by_site(359366, limit=100)
...     # get results with time filtering
...     results = client.chemistry.get_results_by_site(
...         359366,
...         tmin=datetime(2020, 1, 1, tzinfo=timezone.utc),
...         tmax=datetime(2021, 1, 1, tzinfo=timezone.utc)
...     )
get_results_by_sites(national_site_id=None, site_id=None, site_name=None, tmin=None, tmax=None, limit=None, **kwargs)[source]#

Get analysis results for multiple sites with optional time filtering.

Analysis results are linked to sampling sites by national_site_id, which is the recommended (and fastest) way to identify sites. Using site_id or site_name requires an additional API request to look up the sites.

Parameters:
  • national_site_id (list[int] | None) – List of national sampling site IDs (maps to ‘nationellt_provplatsid’ in API)

  • site_id (list[str] | None) – List of site identifiers (maps to ‘platsbeteckning’ in API)

  • site_name (list[str] | None) – List of site names (maps to ‘provplatsnamn’ in API)

  • tmin (str | datetime | None) – Start time (ISO string or datetime object)

  • tmax (str | datetime | None) – End time (ISO string or datetime object)

  • limit (int | None) – Maximum number of results to return

  • **kwargs (Any) – Additional query parameters

Return type:

AnalysisResultCollection

Returns:

Typed collection of groundwater chemistry analysis results

Raises:
  • SGUNotFoundError – If any site_id or site_name matches no site.

  • ValueError – If not exactly one of national_site_id, site_id or site_name is provided, or if a looked-up site has no national_site_id.

Example

>>> from sgu_client import SGUClient
>>> with SGUClient() as client:
...     # get results for multiple sites
...     results = client.chemistry.get_results_by_sites(
...         [359366, 378865],
...         tmin="2020-01-01T00:00:00Z",
...         tmax="2021-01-01T00:00:00Z",
...         limit=1000
...     )
...     print(f"Found {len(results.features)} analysis results")
get_results_by_parameter(parameter, national_site_id=None, site_id=None, site_name=None, tmin=None, tmax=None, limit=None, **kwargs)[source]#

Get analysis results filtered by chemical parameter (e.g., pH, nitrate).

This convenience method makes it easy to retrieve all measurements for a specific chemical parameter, optionally filtered by site(s) and time range. Sites are identified the same way as in get_results_by_site(): national_site_id is recommended, while site_id or site_name require an additional API request.

Parameters:
  • parameter (str) – Parameter name as used by SGU (maps to ‘parameternamn’ in API), e.g. ‘pH’, ‘Bly’, ‘Nitratkväve’, ‘Klorid’

  • national_site_id (int | list[int] | None) – Optional national sampling site ID(s) to filter by

  • site_id (str | list[str] | None) – Optional site identifier(s) to filter by

  • site_name (str | list[str] | None) – Optional site name(s) to filter by

  • tmin (str | datetime | None) – Start time (ISO string or datetime object)

  • tmax (str | datetime | None) – End time (ISO string or datetime object)

  • limit (int | None) – Maximum number of results to return

  • **kwargs (Any) – Additional query parameters

Return type:

AnalysisResultCollection

Returns:

Typed collection of groundwater chemistry analysis results

Raises:
  • SGUNotFoundError – If any site_id or site_name matches no site.

  • ValueError – If more than one of national_site_id, site_id or site_name is provided, or if a looked-up site has no national_site_id.

Example

>>> from sgu_client import SGUClient
>>> with SGUClient() as client:
...     # get all lead measurements since 2020
...     results = client.chemistry.get_results_by_parameter(
...         parameter="Bly",
...         tmin="2020-01-01",
...     )
...     # get pH measurements for a specific site
...     results = client.chemistry.get_results_by_parameter(
...         parameter="pH",
...         national_site_id=359366,
...         tmin="2020-01-01",
...         tmax="2021-01-01"
...     )
...     # ... or multiple sites
...     results = client.chemistry.get_results_by_parameter(
...         parameter="pH",
...         national_site_id=[359366, 378865]
...     )

Model details#

Pydantic models for groundwater chemistry data from SGU API.

pydantic model SamplingSiteProperties[source]#

Properties for a groundwater chemistry sampling site.

field object_id: int | None = None (alias 'objectid')#

Object ID

field national_site_id: int | None = None (alias 'nationellt_provplatsid')#

National sampling site ID

field site_uuid: str | None = None (alias 'provplatsuuid')#

Sampling site UUID

field monitoring_station_id: int | None = None (alias 'overvakningsstation')#

Monitoring station ID

field station_id: str | None = None (alias 'platsbeteckning')#

Station identifier

field site_name: str | None = None (alias 'provplatsnamn')#

Sampling site name

field other_designations: str | None = None (alias 'andra_beteckningar')#

Other site designations

field eu_station_code: str | None = None (alias 'eu_cd')#

EU station code

field eu_groundwater_body: str | None = None (alias 'eucd_gwb')#

EU groundwater body

field site_type_code: str | None = None (alias 'provplatstyp')#

Sampling site type code

field site_type_description: str | None = None (alias 'provplatstyp_tx')#

Sampling site type description

field site_category_code: str | None = None (alias 'provplatskat_bedgr')#

Sampling site category code (assessment basis)

field site_category_description: str | None = None (alias 'provplatskat_bedgr_tx')#

Sampling site category description

field coordinates_hidden: str | None = None (alias 'dold_koordinat')#

Whether coordinates are hidden

field north_coordinate: float | None = None (alias 'n')#

North coordinate

field east_coordinate: float | None = None (alias 'e')#

East coordinate

field positioning_method_code: str | None = None (alias 'positioneringsmetod')#

Positioning method code

field positioning_method_description: str | None = None (alias 'positioneringsmetod_tx')#

Positioning method description

field position_quality_code: str | None = None (alias 'positionskvalitet')#

Position quality code

field position_quality_description: str | None = None (alias 'positionskvalitet_tx')#

Position quality description

field county_code: str | None = None (alias 'lanskod')#

County code

field county: str | None = None (alias 'lan')#

County

field municipality_code: str | None = None (alias 'kommunkod')#

Municipality code

field municipality: str | None = None (alias 'kommun')#

Municipality

field region_code: str | None = None (alias 'region_bdgr')#

Region code (assessment basis)

field region_description: str | None = None (alias 'region_bdgr_tx')#

Region description

field water_district_code: str | None = None (alias 'vattendistrikt')#

Water district code

field water_district_description: str | None = None (alias 'vattendistrikt_tx')#

Water district description

field sub_catchment_name: str | None = None (alias 'delaro_namn')#

Sub-catchment name

field sub_catchment_code: str | None = None (alias 'delaro_ms_cd')#

Sub-catchment MS code

field sub_catchment_uuid: str | None = None (alias 'delaro_uuid')#

Sub-catchment UUID

field water_body_catchment_id: str | None = None (alias 'vattenforekomst_aro_id')#

Water body catchment ID

field main_catchment_id: int | None = None (alias 'huvudavrinningsomrade_id')#

Main catchment area ID

field reference_level: float | None = None (alias 'refniva')#

Reference level

field elevation_system: str | None = None (alias 'hojdsystem')#

Elevation reference system

field elevation_system_description: str | None = None (alias 'hojdsystem_tx')#

Elevation reference system description

field elevation_method_code: str | None = None (alias 'hojdmetod')#

Elevation method code

field elevation_method_description: str | None = None (alias 'hojdmetod_tx')#

Elevation method description

field pipe_height: float | None = None (alias 'rorhojd')#

Pipe height above ground

field pipe_length: float | None = None (alias 'rorlangd')#

Pipe length

field borehole_inclination: float | None = None (alias 'borrhalslutning')#

Borehole inclination

field screen_length: float | None = None (alias 'sillangd')#

Well screen length

field inner_diameter: float | None = None (alias 'innerdiam')#

Inner diameter

field material_code: str | None = None (alias 'material')#

Well material code

field material_description: str | None = None (alias 'material_tx')#

Well material description

field soil_depth_qualifier: str | None = None (alias 'tecken_jorddjup')#

Soil depth sign/qualifier

field soil_depth: float | None = None (alias 'jorddjup')#

Soil depth

field soil_type_code: str | None = None (alias 'jordart')#

Soil type code

field soil_type_description: str | None = None (alias 'jordart_tx')#

Soil type description

field overlying_soil_code: str | None = None (alias 'jord_ovan_jord')#

Overlying soil type code

field overlying_soil_description: str | None = None (alias 'jord_ovan_jord_tx')#

Overlying soil type description

field soil_genesis_code: str | None = None (alias 'genes_jord')#

Soil genesis code

field soil_genesis_description: str | None = None (alias 'genes_jord_tx')#

Soil genesis description

field rock_type_code: str | None = None (alias 'bergart')#

Rock type code

field rock_type_description: str | None = None (alias 'bergart_tx')#

Rock type description

field aquifer_code: str | None = None (alias 'akvifer')#

Aquifer code

field aquifer_description: str | None = None (alias 'akvifer_tx')#

Aquifer description

field groundwater_environment_code: str | None = None (alias 'gvmiljo_bedgr')#

Groundwater environment code (assessment basis)

field groundwater_environment_description: str | None = None (alias 'gvmiljo_bedgr_tx')#

Groundwater environment description

field geohydrological_position_code: str | None = None (alias 'geohylag')#

Geohydrological position code

field geohydrological_position_description: str | None = None (alias 'geohylag_tx')#

Geohydrological position description

field established_date: Annotated[datetime | None] = None (alias 'etabldatum')#

Site establishment date (midnight UTC)

Constraints:
  • func = <function _parse_api_datetime at 0x7fa47d9d60c0>

  • json_schema_input_type = PydanticUndefined

field first_sample_date: Annotated[datetime | None] = None (alias 'forstaprov')#

Date of first sample (midnight UTC)

Constraints:
  • func = <function _parse_api_datetime at 0x7fa47d9d60c0>

  • json_schema_input_type = PydanticUndefined

field latest_sample_date: Annotated[datetime | None] = None (alias 'senasteprov')#

Date of latest sample (midnight UTC)

Constraints:
  • func = <function _parse_api_datetime at 0x7fa47d9d60c0>

  • json_schema_input_type = PydanticUndefined

field sample_count: int | None = None (alias 'antal_prov')#

Number of samples collected

field sampling_occasion_count: int | None = None (alias 'antal_provtillf')#

Number of sampling occasions

field sample_types: str | None = None (alias 'provtyper')#

Sample types collected

field media: str | None = None#

Sampled media

field sampling_purpose_code: str | None = None (alias 'provtagningssyfte')#

Sampling purpose code

field sampling_purpose_description: str | None = None (alias 'provtagningssyften_tx')#

Sampling purpose description

field national_monitoring: str | None = None (alias 'nationell')#

National monitoring program (ja/nej)

field regional_monitoring: str | None = None (alias 'regional')#

Regional monitoring program (ja/nej)

field symbol: str | None = None#

Symbol/classification marker

field analyses_csv_url: str | None = None (alias 'analysdata_csv')#

URL to CSV file with analysis results

field analyses_json_url: str | None = None (alias 'analysdata_json')#

URL to JSON file with analysis results

pydantic model SamplingSite[source]#

A groundwater chemistry sampling site (GeoJSON Feature).

pydantic model AnalysisResultProperties[source]#

Properties for a groundwater chemistry analysis result.

field object_id: int | None = None (alias 'objectid')#

Object ID

field result_id: int | None = None (alias 'resultatid')#

Result ID

field delivery_id: str | None = None (alias 'leveransid')#

Delivery ID

field origin: str | None = None (alias 'ursprung')#

Data origin

field commissioned_by_code: str | None = None (alias 'bestallare')#

Commissioning organisation code

field commissioned_by_description: str | None = None (alias 'bestallare_tx')#

Commissioning organisation

field survey_type: str | None = None (alias 'undersokningstyp')#

Survey type

field commissioned_survey: str | None = None (alias 'bestalld_undersokning')#

Commissioned survey

field performing_organisation: str | None = None (alias 'utfor_org')#

Performing organisation

field performing_organisation_type: str | None = None (alias 'utfor_org_typ')#

Performing organisation type

field report_name: str | None = None (alias 'rapportnamn')#

Report name

field report_name_diva: str | None = None (alias 'rapportnamn_diva')#

Report name in DiVA

field diva_url: str | None = None#

DiVA report URL

field national_site_id: int | None = None (alias 'nationellt_provplatsid')#

National sampling site ID

field monitoring_station_id: int | None = None (alias 'overvakningsstation')#

Monitoring station ID

field site_uuid: str | None = None (alias 'provplatsuuid')#

Sampling site UUID

field site_name: str | None = None (alias 'provplatsnamn')#

Sampling site name

field site_type_code: str | None = None (alias 'provplatstyp')#

Sampling site type code

field county_code: str | None = None (alias 'lanskod')#

County code

field county: str | None = None (alias 'lan')#

County

field municipality_code: str | None = None (alias 'kommunkod')#

Municipality code

field municipality: str | None = None (alias 'kommun')#

Municipality

field east_coordinate: float | None = None (alias 'e')#

East coordinate

field north_coordinate: float | None = None (alias 'n')#

North coordinate

field actual_sampling_point_east: float | None = None (alias 'fkt_provpunkt_e')#

Actual sampling point east coordinate

field actual_sampling_point_north: float | None = None (alias 'fkt_provpunkt_n')#

Actual sampling point north coordinate

field sampling_organisation_code: str | None = None (alias 'provtag_org')#

Sampling organisation code

field sampling_organisation_description: str | None = None (alias 'provtag_org_tx')#

Sampling organisation

field sampling_date: Annotated[datetime | None] = None (alias 'provtagningsdatum')#

Sampling date (UTC)

Constraints:
  • func = <function _parse_api_datetime at 0x7fa47d9d60c0>

  • json_schema_input_type = PydanticUndefined

field sampling_end_date: Annotated[datetime | None] = None (alias 'provtagning_slutdatum')#

Sampling end date (UTC)

Constraints:
  • func = <function _parse_api_datetime at 0x7fa47d9d60c0>

  • json_schema_input_type = PydanticUndefined

field sampling_purpose_code: str | None = None (alias 'provtagningssyfte')#

Sampling purpose code

field sampling_purpose_description: str | None = None (alias 'provtagningssyfte_tx')#

Sampling purpose description

field sampling_method: str | None = None (alias 'provtagningsmetod')#

Sampling method

field sampling_method_url: str | None = None (alias 'provtagningsmetod_url')#

Sampling method URL

field sample_data_type: str | None = None (alias 'provdatatyp')#

Sample data type

field site_environment: str | None = None (alias 'provplatsmiljo')#

Sampling site environment

field media: str | None = None#

Sampled media

field accredited_sampler: str | None = None (alias 'ackrediteradprovtagare')#

Accredited sampler

field direct_treatment: str | None = None (alias 'direktbehandling')#

Direct sample treatment

field direct_treatment_url: str | None = None (alias 'direktbehandling_url')#

Direct sample treatment URL

field filtered: str | None = None (alias 'filtrerat')#

Whether the sample was filtered

field filter_size: str | None = None (alias 'filterstorlek')#

Filter size

field purge_time: str | None = None (alias 'omsattningstid')#

Well purge time

field purge_volume: str | None = None (alias 'omsattningsvolym')#

Well purge volume

field purge_to_sample_time: str | None = None (alias 'omsatt_tid_till_prov')#

Time from purge to sampling

field sample_comment: str | None = None (alias 'kommentar_prov')#

Sample comment

field original_sample_code: str | None = None (alias 'provkodoriginal')#

Original sample code

field laboratory: str | None = None (alias 'laboratorium')#

Laboratory name

field laboratory_description: str | None = None (alias 'laboratorium_tx')#

Laboratory description

field performing_lab_id: str | None = None (alias 'utforarlabbid')#

Performing laboratory ID

field performing_lab_description: str | None = None (alias 'utforarlabbid_tx')#

Performing laboratory description

field lab_report_code: str | None = None (alias 'rapportkodlabb')#

Laboratory report code

field registration_date: Annotated[datetime | None] = None (alias 'registreringsdatum')#

Registration date (UTC)

Constraints:
  • func = <function _parse_api_datetime at 0x7fa47d9d60c0>

  • json_schema_input_type = PydanticUndefined

field analysis_date: Annotated[datetime | None] = None (alias 'analysdatum')#

Analysis date (UTC)

Constraints:
  • func = <function _parse_api_datetime at 0x7fa47d9d60c0>

  • json_schema_input_type = PydanticUndefined

field sample_preparation: str | None = None (alias 'provberedning')#

Sample preparation method

field sample_preparation_url: str | None = None (alias 'provberedning_url')#

Sample preparation method URL

field sample_container_code: str | None = None (alias 'provkarl')#

Sample container code

field sample_container_description: str | None = None (alias 'provkarl_tx')#

Sample container description

field sample_storage_code: str | None = None (alias 'provlagring')#

Sample storage code

field sample_storage_description: str | None = None (alias 'provlagring_tx')#

Sample storage description

field parameter_id: str | None = None (alias 'ntlkemiparameterid')#

National chemistry parameter ID

field parameter_name: str | None = None (alias 'parameternamn')#

Parameter/chemical substance name

field parameter_comment: str | None = None (alias 'parameter_anm')#

Parameter comment

field parameter_group: str | None = None (alias 'parametergrupp')#

Parameter group

field cas_number: str | None = None (alias 'cas_kod')#

CAS registry number

field measurement_value_text: str | None = None (alias 'matvardetext')#

Measurement value as text

field measurement_value: float | None = None (alias 'matvardetal')#

Measurement value (numeric)

field measurement_value_annotation: str | None = None (alias 'matvardetal_anm')#

Measurement value annotation/qualifier

field measurement_value_span: str | None = None (alias 'matvardespar')#

Measurement value span/range

field unit: str | None = None (alias 'enhet')#

Unit of measurement

field unit_description: str | None = None (alias 'enhet_tx')#

Unit of measurement description

field measurement_standard_code: str | None = None (alias 'matvstd')#

Measurement standard code

field measurement_standard_description: str | None = None (alias 'matvstd_tx')#

Measurement standard description

field quantification_limit: str | None = None (alias 'loq')#

Limit of quantification (LOQ)

field detection_limit: str | None = None (alias 'lod')#

Limit of detection (LOD)

field measurement_uncertainty: str | None = None (alias 'matosakerhet')#

Measurement uncertainty

field measurement_uncertainty_unit_code: str | None = None (alias 'matosakerhetenhet')#

Measurement uncertainty unit code

field measurement_uncertainty_unit_description: str | None = None (alias 'matosakerhetenhet_tx')#

Measurement uncertainty unit

field measurement_uncertainty_type_code: str | None = None (alias 'matosakerhettyp')#

Measurement uncertainty type code

field measurement_uncertainty_type_description: str | None = None (alias 'matosakerhettyp_tx')#

Measurement uncertainty type

field measurement_comment: str | None = None (alias 'kommentar_matvarde')#

Measurement value comment

field method: str | None = None (alias 'analysmetod')#

Analysis method used

field method_url: str | None = None (alias 'analysmetod_url')#

Analysis method URL

field accredited_method: str | None = None (alias 'ackrediteradmetod')#

Accredited analysis method

field analysis_instrument: str | None = None (alias 'analysinstrument')#

Analysis instrument

field analysis_instrument_url: str | None = None (alias 'analysinstrument_url')#

Analysis instrument URL

field water_type_code: str | None = None (alias 'vattentyp')#

Water type code

field water_type_description: str | None = None (alias 'vattentyp_tx')#

Water type description

field quality_flag: str | None = None (alias 'kvalitetsflagga')#

Quality flag

field review_comment: str | None = None (alias 'granskningskommentar')#

Review comment

pydantic model AnalysisResult[source]#

A groundwater chemistry analysis result (GeoJSON Feature).

pydantic model SamplingSiteCollection[source]#

Collection of groundwater chemistry sampling sites (GeoJSON FeatureCollection).

Its DataFrame has longitude and latitude columns, null for sites without a geometry.

Examples

>>> from sgu_client import SGUClient
>>> with SGUClient() as client:
...     sites = client.chemistry.get_sampling_sites(limit=10)
...     df = sites.to_dataframe()
...     print(df[['national_site_id', 'station_id', 'site_name']].head())
pydantic model AnalysisResultCollection[source]#

Collection of groundwater chemistry analysis results (GeoJSON FeatureCollection).

Its DataFrame has no geometry columns. Sorted by sampling_date; to_series() defaults to measurement_value. pivot_by_parameter() gives one column per chemical parameter.

Examples

>>> from sgu_client import SGUClient
>>> with SGUClient() as client:
...     results = client.chemistry.get_results_by_site(359366, limit=100)
...     df = results.to_dataframe()
...     print(df[['sampling_date', 'parameter_name', 'measurement_value']])
pivot_by_parameter(values='measurement_value', index='sampling_date', columns='parameter_name', aggfunc='mean')[source]#

Pivot analysis results by parameter for easier time series analysis.

This creates a wide-format DataFrame where each chemical parameter becomes a column, making it easy to analyze multiple parameters over time.

Parameters:
  • values (str) – Column to use for values (default: ‘measurement_value’)

  • index (str) – Column to use as index (default: ‘sampling_date’)

  • columns (str) – Column to pivot into columns (default: ‘parameter_name’)

  • aggfunc (str) – Aggregation function if there are duplicate index/column pairs (default: ‘mean’). Can be ‘mean’, ‘median’, ‘first’, ‘last’, etc.

Return type:

DataFrame

Returns:

Pivoted DataFrame with parameters as columns.

Example

>>> from sgu_client import SGUClient
>>> with SGUClient() as client:
...     results = client.chemistry.get_results_by_site(359366)
...     df_pivot = results.pivot_by_parameter()
...     # now df_pivot has columns like 'pH', 'Nitratkväve', 'Klorid', etc.