项目作者: cjtu

项目描述 :
A python library for impact crater data science
高级语言: Python
项目地址: git://github.com/cjtu/craterpy.git
创建时间: 2017-04-17T02:10:37Z
项目社区:https://github.com/cjtu/craterpy

开源协议:MIT License

下载



Craterpy: Impact crater data science in Python.

Overview

Craterpy makes it easier to work with impact crater data in Python. Highlights:

  • convert a table of crater data to a GeoDataFrame or GIS-ready shapefile
  • extract zonal statistics associated with each crater in circlular or annular regions (rasterstats)
  • eliminate some pain points of planetary GIS analysis (antimeridian wrapping, projection conversions, etc.)

Note: craterpy is not a detection algorithm (e.g., PyCDA), nor is it a crater count age dating tool (see craterstats).

Note: Craterpy is in beta. We appreciate bug reports and feature requests on the issues board.

Examples

All craters on the Moon > 2km.

  1. from craterpy import CraterDatabase
  2. cdb = CraterDatabase('lunar_crater_database_robbins_2018.csv', "Moon", units="km")
  3. cdb.plot(linewidth=0.25, alpha=0.25, color='gray')

Lunar craters plot

Define cicular/annular regions and export to GIS-ready shapefiles:

  1. cdb.add_circles("craters", size=1) # Crater interiors
  2. cdb.add_annuli("ejecta", inner=1, outer=3) # Annulus from rim to 2 radii past the rim (excludes interior)
  3. cdb.craters.to_file("lunar_craters.geojson")
  4. cdb.ejecta.to_file("lunar_ejecta.geojson")

Plot on a raster

  1. cdb = CraterDatabase('vesta_craters.csv', "Vesta", units="m")
  2. im = plt.imread('vesta.tif')
  3. ax = cdb.plot(alpha=0.5, color='tab:green')
  4. ax.imshow(im, extent=(-180, 180, -90, 90), cmap='gray')

Vesta map plot

Compute raster image statistics on each crater geometry.

  1. import pandas as pd
  2. df = pd.DataFrame({'Name': ["Orientale", "Copernicus", "Tycho"],
  3. 'Lat': [-19.9, 9.62, -43.35],
  4. 'Lon': [-94.7, -20.08, -11.35],
  5. 'Rad': [250., 48., 42.]})
  6. cdb = CraterDatabase(df, "Moon", units="km")
  7. # Define regions for central peak, crater floor, and rim (sizes in crater radii)
  8. cdb.add_annuli("peak", 0, 0.1)
  9. cdb.add_annuli("floor", 0.3, 0.6)
  10. cdb.add_annuli("rim", 1.0, 1.2)
  11. # DEM is a geotiff with elevation relative to reference Moon in meters
  12. stats = cdb.get_stats("dem.tif", regions=['floor', 'peak', 'rim'], stats=['mean', 'std'])
  13. print(stats)
Name Lat Lon Rad mean_floor std_floor mean_peak std_peak mean_rim std_rim
Orientale -19.90 -94.70 250.0 -2400.0 400.0 -2800.0 100.0 400.0 1100.0
Compernicus 9.62 -20.08 48.0 -3400.0 200.0 -3400.0 100.0 -0.0 200.0
Tycho -43.35 -11.35 42.0 -3200.0 400.0 -2100.0 500.0 900.0 400.0

See the full craterpy documentation on Read the Docs.

Installation

With pip:

  1. pip install craterpy

From the repo with poetry (for latest version & to contribute). First fork and clone the repository, then:

  1. # Install craterpy with poetry
  2. $ cd craterpy
  3. $ poetry install
  4. # Check installation version
  5. poetry version
  6. # Activate the venv
  7. $ poetry shell
  8. $ which python
  9. # Or open a Jupyter notebook
  10. $ poetry run jupyter notebook
  • Note: Craterpy is currently only tested on Ubuntu and OS X. If you would like to use craterpy on Windows, check out the Windows Subsystem for Linux (WSL).

Trouble installing craterpy? Let us know on the issues board.

Documentation

Full API documentation and usage examples are available at readthedocs.

Contributing

There are two major ways you can help improve craterpy:

Bug Reporting and Feature Requests

You can report bugs or request new features on the issues board.

Contributing Directly

Want to fix a bug / implement a feature / fix some documentation? We welcome pull requests from all new contributors! You (yes you!) can help us make craterpy as good as it can be! See CONTRIBUTING.rst for details on how to get started - first time GitHub contributors welcome - and encouraged!

Citing craterpy

Craterpy is MIT Licenced and is free to use with attribution. Citation information can be found here.