Skip to content

Commit

Permalink
tutorials keep me busy
Browse files Browse the repository at this point in the history
  • Loading branch information
MiguelonGonzalez committed Mar 1, 2022
1 parent f7424f6 commit 589dbf9
Show file tree
Hide file tree
Showing 6 changed files with 255 additions and 110 deletions.
2 changes: 1 addition & 1 deletion dinsar/agregado.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ def set_estacion(self, estacion=None, bd=None, way='nearest', orden=1,
self._info_estaciones = {'estacion':_estacion, 'bd':bd_object}

if not _silent:
print(f"Fijada la estación: {self.estacion.name}"
print(f"Fijada la estación: {self.estacion.name} "
f"según el método '{way}'.")

return self
Expand Down
57 changes: 57 additions & 0 deletions examples/Adding other database to the model.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"id": "8159acc0",
"metadata": {},
"outputs": [],
"source": [
"from shapely.geometry import Point\n",
"import random\n",
"\n",
"x1, y1, x2, y2 = Doñana.get('Asc').gdf.total_bounds\n",
"\n",
"random_point = lambda x1, y1, x2, y2 : Point(random.uniform(x1, x2), random.uniform(y1, y2))\n",
"\n",
"# Definición de la base de datos (pandas.DataFrame):\n",
"columns, values = [i for i in 'ABCDE'], [np.random.random(60) for i in range(5)]\n",
"df_table = {i:j for i,j in zip(columns, values)}\n",
"df = pd.DataFrame(df_table, index=pd.date_range(start='2015', end='2020', freq='M'))\n",
"df = df.melt(var_name='Nombre', value_name='Valores', ignore_index=False)\n",
"df.index.name = 'Fechas'\n",
"df.reset_index(inplace=True)\n",
"\n",
"# Definición de un archivo espacial\n",
"table = {'Nombre':[i for i in 'ABCDE'],\n",
" 'geometry':[random_point(x1, y1, x2, y2) for i in range(5)]}\n",
"gdf = gpd.GeoDataFrame(table, crs=25830)\n",
"\n",
"gps = dinsar.DataBase(df, name='gps', units='cm', color='black')\n",
"gps.append_geometry(gdf)\n",
"Doñana.append(gps)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.11"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
6 changes: 4 additions & 2 deletions examples/Creating a dinsar model.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
"\n",
"---------------------------------------------------------------------------------------------------------------------------\n",
"\n",
"<h1><center>Creating a dinsar Model</center></h1>\n",
"\n",
"## 1. Creation of a Model\n",
"The dinsar package design holds a data **model** as the main object around which all of the program functionalities spin around. This model will include all the DInSAR datasets and databases that are consulted in the study area and is created through the `Model` class. Since the simplest way of analyzing DInSAR deformation points (also called persistent or permanent scatterers; PS) is through their **aggregation into polygons**, the initialization of this class requieres a polygonal spatial file, that should be introduced as a relative path to its ubication. This way, each of these polygons will define the different analysis areas of the model -analogous to [ADA's](https://open.igme.es/xmlui/bitstream/handle/20.500.12468/708/fast_detection_ground_2017.pdf?sequence=1) (Active Deformation Areas), called in the code as **agregados** and hereinafter as *aggregates*.\n",
"\n",
Expand Down Expand Up @@ -280,7 +282,7 @@
},
{
"cell_type": "markdown",
"id": "836305ca",
"id": "2b334d20",
"metadata": {},
"source": [
"## 5. Main functions of Model object:\n",
Expand All @@ -293,7 +295,7 @@
{
"cell_type": "code",
"execution_count": 7,
"id": "da3c0596",
"id": "dd519337",
"metadata": {},
"outputs": [
{
Expand Down
212 changes: 105 additions & 107 deletions examples/Studying an Aggregate.ipynb

Large diffs are not rendered by default.

39 changes: 39 additions & 0 deletions examples/Visualizing with plot and mapa methods..ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"id": "0604ed54",
"metadata": {},
"outputs": [],
"source": [
"import dinsar\n",
"\n",
"# Para centrar las gráficas salientes en un notebook de Jupyter.\n",
"from IPython.core.display import HTML\n",
"HTML(\"\"\"<style>.output_png {display: table-cell; text-align: center; vertical-align: middle;}</style>\"\"\")"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.11"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
49 changes: 49 additions & 0 deletions examples/Working with model parts.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"id": "37fef053",
"metadata": {},
"outputs": [],
"source": [
" # Cojo los cinco primeros PS del Dataset 'Ascending' (dessde fuera del modelo ) y calculo su deformación promedio\n",
"ps = Asc.ps[0:5] \n",
"Asc.subset(ps).plot(plot_average=True)\n",
"\n",
"# Cojo el primer piezómetro de la base de datos de piezometría y ploteo su serie temporal\n",
"piezo = bbdd.piezos[0]\n",
"bbdd.plot(piezo)\n",
"\n",
"# A través del método 'take' accedo al array con su serie tempral: --> bbdd.take(piezo)\n",
"\n",
"# Selecciono la estación de Almonte y ploteo su serie temporal según su desviación acumulada\n",
"# Puedo ver qué estaciones hay en la base de datos así: --> precipi.estaciones\n",
"precipi.plot('Almonte', values='dsv')\n",
"\n",
"precipi.estaciones"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.11"
}
},
"nbformat": 4,
"nbformat_minor": 5
}

0 comments on commit 589dbf9

Please sign in to comment.