Skip to content

Script to convert brodata GMW+GLD to hydropandas ObsCollection #10

Description

@dbrakenhoff

Perhaps useful at some point. Maybe here, maybe in hydropandas.

import brodata
import hydropandas as hpd


gmw_df, gld_df = brodata.gmw.get_data_in_extent(
    extent, to_zip="bro_download_gmw_gld.zip"
)
obslist = []
for i in gmw_df.index:
    if i not in gld_df.index:
        print(f"No obs for {i}")
        continue
    metadata = {
        "x": gmw_df.loc[i, "x"],
        "y": gmw_df.loc[i, "y"],
        "screen_top": gmw_df.loc[i, "screenTopPosition"],
        "screen_bottom": gmw_df.loc[i, "screenBottomPosition"],
        "ground_level": gmw_df.loc[i, "groundLevelPosition"],
        "tube_top": gmw_df.loc[i, "tubeTopPosition"],
        "tube_nr": i[-1],
        "unit": "mNAP",
        "source": "BRO",
        "location": i[0],
        "metadata_available": True,
        "name": f"{i[0]}_{i[1]:03g}",
    }
    obs = gld_df.loc[i, "observation"]
    obs_ok = obs.loc[obs.qualifier == "goedgekeurd"]  # only approved obs, might also not be what you want!

    # NOTE: resample occurs here, which is probably not always what you want!
    obs_1d = obs_ok.resample("1D").first()

    obslist.append(hpd.GroundwaterObs(obs_1d, **metadata))

oc = hpd.ObsCollection.from_list(obs_list=obslist)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions