In [1]:
from charistools.convertors import Csv2Hypsometry

In [2]:
%cd /Users/brodzik/charistools/source/charistools/test


/Users/brodzik/charistools/source/charistools/test

In [3]:
%ls


Kta_hypso_100m.csv      modis_tiles_config.ini  test_hypsometry.py
__init__.py             test.sca_by_elev.txt    test_modelEnv.py
all_tests.py            test_convertors.py

In [4]:
help(Csv2Hypsometry)


Help on function Csv2Hypsometry in module charistools.convertors:

Csv2Hypsometry(csv_filename, hyps_filename, comments=[], verbose=False)
    from charistools.convertors import Csv2Hypsometry
    
    charistools.convertors.Csv2Hypsometry(csv_filename, hyps_filename,
        comments=[], verbose=False)
    
    Arguments:
        csv_filename : name of 3-column comma-separated value file
            1st column is ignored,
            2nd column: elevation in meters at
                bottom of elevation band
            3rd column: area in km^2 for the elevation band
        hyps_filename : name of file to write converted data to
        comments : list of strings
            optional comments to add to output file
            Name of input file will be written as the first line
            of comments
        verbose : boolean, default False
    
    The Csv2Hypsometry utility converts a 3-column csv file with
    hyposmetric information (for example from ArcGIS) into a
    charistools Hypsometry file.
    
    Assumes first line in the csv file is column headers, and ignores it.


In [5]:
%cat Kta_hypso_100m.csv


ID,Elevation,Area_sq_km
1,500,85.
2,600,609.
3,700,1007.
4,800,1609.
5,900,2752.
6,1000,3565.
7,1100,4492.
8,1200,5623.
9,1300,6255.
10,1400,7316.
11,1500,8087.
12,1600,9048.
13,1700,9737.
14,1800,10935.
15,1900,11717.
16,2000,12465.
17,2100,12050.
18,2200,11631.
19,2300,10688.
20,2400,8943.
21,2500,8165.
22,2600,7406.
23,2700,6982.
24,2800,6430.
25,2900,6147.
26,3000,5630.
27,3100,5476.
28,3200,5245.
29,3300,5166.
30,3400,5035.
31,3500,4702.
32,3600,4321.
33,3700,4241.
34,3800,4328.
35,3900,4326.
36,4000,4474.
37,4100,4685.
38,4200,4773.
39,4300,4416.
40,4400,4138.
41,4500,4425.
42,4600,4169.
43,4700,4362.
44,4800,4323.
45,4900,4316.
46,5000,4245.
47,5100,3704.
48,5200,3253.
49,5300,2833.
50,5400,2570.
51,5500,2435.
52,5600,2017.
53,5700,1691.
54,5800,1456.
55,5900,1099.
56,6000,899.
57,6100,603.
58,6200,369.
59,6300,230.
60,6400,162.
61,6500,115.
62,6600,62.
63,6700,17.
64,6800,6.
65,6900,1.

In [6]:
csv_filename = "Kta_hypso_100m.csv"
out_filename = "Kta_hypso_100m.txt"
comments = ["Some test comments here about how Kta_Hypso was created."]

In [7]:
Csv2Hypsometry(csv_filename, out_filename,comments, verbose=True)


charistools.hypsometry : wrote hypsometry data to Kta_hypso_100m.txt
charistools.hypsometry : 2 comments.
charistools.hypsometry : 1 dates.
charistools.hypsometry : 65 elevations.
Out[7]:
True

In [8]:
%cat Kta_hypso_100m.txt


# Hypsometry converted from Kta_hypso_100m.csv
# Some test comments here about how Kta_Hypso was created.
65
500 600 700 800 900 1000 1100 1200 1300 1400 1500 1600 1700 1800 1900 2000 2100 2200 2300 2400 2500 2600 2700 2800 2900 3000 3100 3200 3300 3400 3500 3600 3700 3800 3900 4000 4100 4200 4300 4400 4500 4600 4700 4800 4900 5000 5100 5200 5300 5400 5500 5600 5700 5800 5900 6000 6100 6200 6300 6400 6500 6600 6700 6800 6900
9999 99 99 999 85.000000 609.000000 1007.000000 1609.000000 2752.000000 3565.000000 4492.000000 5623.000000 6255.000000 7316.000000 8087.000000 9048.000000 9737.000000 10935.000000 11717.000000 12465.000000 12050.000000 11631.000000 10688.000000 8943.000000 8165.000000 7406.000000 6982.000000 6430.000000 6147.000000 5630.000000 5476.000000 5245.000000 5166.000000 5035.000000 4702.000000 4321.000000 4241.000000 4328.000000 4326.000000 4474.000000 4685.000000 4773.000000 4416.000000 4138.000000 4425.000000 4169.000000 4362.000000 4323.000000 4316.000000 4245.000000 3704.000000 3253.000000 2833.000000 2570.000000 2435.000000 2017.000000 1691.000000 1456.000000 1099.000000 899.000000 603.000000 369.000000 230.000000 162.000000 115.000000 62.000000 17.000000 6.000000 1.000000

In [ ]: