Anderson Banihirwe
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    --- title: 'Intake-esm Design Document' --- ## Table of Contents [TOC] ## Goal Be able to _search_, _discover_, and _ingest_ climate datasets from major model inter-comparison projects such as CMIP into xarray by eliminating the need for the user to know specific locations (file path) of their data set of interest. ## Introduction [`Intake-esm`](https://github.com/NCAR/intake-esm) provides an intake plugin for creating file-based [intake](https://intake.readthedocs.io/en/latest/) catalogs for climate data from project efforts such as the Coupled Model Intercomparison Project (CMIP) and the Community Earth System Model (CESM) Large Ensemble Project. These projects produce a huge of amount climate data persisted on tape, disk storage components across multiple (in the order of ~ 300,000) netCDF files. Finding, investigating, loading these files into data array containers such as xarray can be a daunting task due to the large number of files a user may be interested in. ### Related Work - [ESGF Search API](https://github.com/ESGF/esgf.github.io/wiki/ESGF_Search_REST_API) - They have already thought about many of these problems - [STAC Datacube Extension](https://github.com/radiantearth/stac-spec/tree/master/extensions/datacube) - [AOSpy](https://aospy.readthedocs.io/en/latest/) - aospy enables firing off multiple calculations in parallel using the permutation of an arbitrary number of climate models, simulations, variables to be computed, date ranges, sub-annual-sampling, and many other parameters. ## Data Holdings ### Supported So far, `intake-esm` supports the following data holdings: - **CMIP5** Data Holdings stored on NCAR's GLADE Storage system - Directory Structure: <activity>/ <product>/ <institute>/ <model>/ <experiment>/ <frequency>/ <modeling realm>/ <MIP table>/ <ensemble member>/ <version number>/ <variable name>/ <CMOR filename>.nc - CMOR filename: <variable name>_<MIP table>_<model>_<experiment>_<ensemble member> [_<temporal subset>][_<geographical info>].nc - format: netCDF - **CMIP6** Data Holdings stored on NCAR's GLADE Storage system - Directory Structure: <mip_era>/ <activity_id>/ <institution_id>/ <source_id>/ <experiment_id>/ <member_id>/ <table_id>/ <variable_id>/ <grid_label>/ <version>/ <CMOR filename>.nc - CMOR filename: <variable_id>_<table_id>_<source_id>_<experiment_id>_ <member_id>_<grid_label>[_<time_range>].nc - Note: For time-invariant fields, the last segment (`time_range`) above is omitted. - Format: netCDF - **CESM1-LENS** data holdings stored on both NCAR's GLADE Storage system and HPSS Tapes - Filename template: - Format: netCDF - **CESM1-LENS** data publicly available on Amazon S3 (us-west-2 region) --> https://ncar-cesm-lens.s3.amazonaws.com/ - Bucket structure: <component>/<frequency>/cesmLE-<experiment>-<variable>.zarr Where: - component = atm (atmosphere), lnd (land), ocn (ocean), ice_nh or ice_sh (ice, northern and southern hemispheres) - frequency = monthly, daily, or hourly6-startYear-endYear (6-hourly data are available for distinct periods) - Format: zarr - **ECMWF ERA5** data holdings stored on NCAR's GLADE Storage system - Filename template: - Format: netCDF - **NA-CORDEX** data holdings stored on NCAR's GLADE Storage system - Filename template: <variable>.<experiment>.<global_climate_model>.<regional_climate_model>. <frequency>.<grid>.<bias_corrected_or_raw>.nc - Format: netCDF ### Need Support - **CMIP6** data holdings in zarr format, including in Pangeo's Google Cloud Storage, but also on LDEO's linux machines and elsewhere. - Example: <https://console.cloud.google.com/storage/browser/pangeo-cmip6> - Directory Structure: <mip_era>/ <activity_id>/ <institution_id>/ <source_id>/ <experiment_id>/ <member_id>/ <table_id>/ <variable_id>/ <grid_label> - Zarr store structure: - At the <grid_label> level, the directory is a standard zarr store, with files .zattrs,.zgroup,.zmetadata and a subdirectory named for each coordinate and variable - Example: [`pangeo-cmip6/AR6_WG1/CMIP/NASA-GISS/GISS-E2-1-G/piControl/r1i1p1f1/Amon/va/gn/`](https://console.cloud.google.com/storage/browser/pangeo-cmip6/AR6_WG1/CMIP/NASA-GISS/GISS-E2-1-G/piControl/r1i1p1f1/Amon/va/gn/) - It might be nice if the zarr store had the suffix `.zarr`, i.e. `gn.zarr`. - Format: zarr ## Design `intake-esm` provides an interface that permits searching and ingesting datasets. ### Using collections It is important to distinguish between generating `intake-esm` collections and *using* those collections. `intake-esm` currently has code to crawl directories and parse filenames to build collections. The functionality for building collections has no inherent dependence on functionality for usage, other than the collection build must yeild a `collection` that conforms appropriately. #### `collection` Collections are defined in a yaml file. ##### Dataset-specific attributes A `collection` is defined by a list of attributes that define a particular dataset. For instance, for CMIP we have ```yaml collection_columns: - activity_id - institution_id - source_id - experiment_id - member_id - table_id - variable_id - grid_label - path ``` ##### Control of returned datasets There are set of attributes that determine how datasets are returned to the user. `intake-esm` returns a dictionary of datasets where the keys are compatible groups and the values are datasets that have been concatenated and merged according to specification. ```yaml # define the set of attributes for which common values indicate # datasets that can be merged or concatenated. `intake-esm` applies # `df.groupby(col_compatible_dset_attrs)` to determine the unique groups col_compatible_dset_attrs: - institution_id - source_id - experiment_id - table_id - grid_label # define a set of new dimensions across which to # concatenate and construct a return dataset. col_concat_newdim_attrs: - member_id # define a set of collection attributes across which to # merge returned datasets col_merge_attrs: - variable_id ``` `intake-esm` always concatenates across `time`. ##### Private attributes Additional attributes are "private"; these enable `intake-esm` to appropriately access the data. For instance: - `resource_type`: string, [posix, HPSS, gs, s3,...] - `direct_access`: boolean, can the data be read directly? - `data_format`: string, netCDF, Zarr, etc. These attributes need to be set by the builder of the catalog. ### Building collections Building collections could happen in a variety of ways. At present, `intake-esm` relies on a yaml file to control building. We make #### `storage_resource` A `storage_resource` object is defined by the following attributes: - `name`: string - `resource_type`: string, [posix, HPSS, gs, s3,...] - `direct_access`: boolean, can the data be read directly? - `data_format`: string, netCDF or Zarr - `urlpath`: string, path to data tree - `exclude_dirs`: list of string, glob patterns to omit ## Application Programming Interface (API) - Loading Dataset collection catalog ```python import intake col = intake.open_esm_metadatastore(collection_name="GLADE-CMIP6") ``` - Search and Discovery ```python cat = col.search(variable_id=['hfls'], table_id=['Amon'], \ experiment_id=['1pctCO2', 'histSST'], \ source_id=['CanESM5', 'IPSL-CM6A-LR']) ``` - Data Loading ```python dsets = cat.to_xarray(chunks={'time': 100}) ``` ## CSV Based Approach At Lamont we have had success with a CSV-file catalog that looks like this: ```csv activity_id,institution_id,source_id,experiment_id,member_id,table_id,variable_id,grid_label,zstore AerChemMIP,BCC,BCC-ESM1,ssp370,r1i1p1f1,Amon,pr,gn,gs://pangeo-cmip6/AR6_WG1/AerChemMIP/BCC/BCC-ESM1/ssp370/r1i1p1f1/Amon/pr/gn/ AerChemMIP,BCC,BCC-ESM1,ssp370,r1i1p1f1,Amon,ts,gn,gs://pangeo-cmip6/AR6_WG1/AerChemMIP/BCC/BCC-ESM1/ssp370/r1i1p1f1/Amon/ts/gn/ AerChemMIP,BCC,BCC-ESM1,ssp370,r1i1p1f1,Amon,ua,gn,gs://pangeo-cmip6/AR6_WG1/AerChemMIP/BCC/BCC-ESM1/ssp370/r1i1p1f1/Amon/ua/gn/ ``` This format is basically ad-hoc but it really fits the way people want to use the data. You can load it in pandas, a familiar tool for most, and execute complex queries that way. Together with [qgrid](https://github.com/quantopian/qgrid), one can very quickly make a fast, interactive, browseable table that can be used to sort and filter the data. Naomi showed examples of this working well on files with 20,000+ rows. We are convinced that a CSV catalog is a useful way to index this data. CSV is - simple: everyone can read and write it (even non-python people) - interoprable with many different tools (not locked into one package) - capable of describing both cloud and file-based holdings - flexible enough to encompass the diversity of ESM datasets; the choice of columns is totally arbitrary and can be tailored to the specific dataset _So where does intake fit in?_ We opened an [issue](https://github.com/intake/intake/issues/417) to discuss this. Basically, intake provides the ability load the data into python, via its `.read()` and `.to_dask()` methods. In that issue, Martin Durant very quickly whipped up an example of intake loading such a CSV catalog, providing a qgrid widget, and loading the selected data to xarray. We think this could be the right path for our project here. Specifically - All intake esm datasets are catalogged into a simple csv file. - Intake can read this file and provide tools for loading the data. - Or users can bypass intake and just look at the csv file (useful for other languages). Some of the major open questsions are: - What is the specification for the CSV file? Naomi chose `zstore` as the name of the data path. I suggested the more generic `path`. In general, we might want to distinguish between - columns related to data attributes (e.g. `activity_id`, `source_id`) - columns related to file details (e.g. `path`, maybe also `format={zarr|netcdf}`) - Do we want to support aggregation of multiple files into a single dataset? This is highly complex. Intake-esm does this now, in a fairly ad-hoc way. This is emerging as one of the major bariers to cloud vs hpc interoperability. As things stand now, we would need to re-implement all of that same logic in a cloud-based catalog. A big practical difference is that Naomi has already conconcatenated all the time ranges into a single zarr store before uploading, so we have lost the 1:1 correspondence between netcdf files and zarr stores. Ideally, on cheyenne, this concatenation could happen on the fly when loading a dataset. If the answer here is **yes**, we need to think about the best place for such code to live. I think that specifying complex merge options for xarray datasets is a very general problem that would be useful in many different contexts, so perhaps should not live in an intake or ESM specific package. We should meet asap to discuss these challenges and make a strategy for going forward. ## Proposal (2019-10-02) - We define an **ESM catalog spec**, ideally as a csv file. This would contain aribtrary metadata columns (e.g. activity_id) plus perhaps some required ones (filetype, path). The paths can be files paths or web endpoints, doesn't matter. This lives in a standalone repo with a simple spec validator script. Generating catalogs is the responsibility of the data provider. Can be as simple as walking a directory tree or something else. - https://github.com/di/vladiate - Maybe we also need a `meta.yaml` file for column definitions, etc. - We refactor intake-esm around the new catalog spec. Now its job is to parse the catalog and provide an intake interface to loading the data. No special cases. If the catalog matches the spec, intake-esm can handle it, period. ## Appendix and FAQ :::info **TODO**! ::: ###### tags: `ncar` `pangeo`

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully