Skip to content

Add region-wide hypsometry files? #56

Description

@fmaussion

RGI version
RGI v7.0

A user asked for RGI to provide this. Its a fairly easy thing to compute, but we could. Here is the code:

import pandas as pd
import glob, os

files = sorted(glob.glob('RGIV70G/RGI2000-v7.0-G-*/RGI2000-v7.0-G-*-hypsometry.csv'))
files_attrs = sorted(glob.glob('RGIV70G/RGI2000-v7.0-G-*/RGI2000-v7.0-G-*-attributes.csv'))

assert len(files) == len(files_attrs)

odf = pd.DataFrame()
odfs = pd.DataFrame()
for f, fa in zip(files, files_attrs):
    
    df = pd.read_csv(f, index_col=0)
    area = df.pop('area_km2')
    df = (df/1000).mul(area, axis=0)

    dfa = pd.read_csv(fa, index_col=0)

    reg = f'{dfa.o1region.unique()[0]:02d}'
    subregs = sorted(dfa.o2region.unique())
    
    
    odf[reg] = df.sum()

    for sreg in subregs:
        odfs[sreg] = df.loc[dfa.o2region == sreg].sum()

odf.to_csv('RGI2000-v7.0-G-hypsometry_o1-regions.csv')
odfs.to_csv('RGI2000-v7.0-G-hypsometry_o2-regions.csv')

Here is the files:

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

    RGI 7.0refers to RGI 7.0enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions