pikobs 0.0.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (100) hide show
  1. pikobs/__init__.py +19 -0
  2. pikobs/__not_used/plot_proj.py +79 -0
  3. pikobs/__not_used/vdedr2.py +104 -0
  4. pikobs/__not_used/vdedr3.py +734 -0
  5. pikobs/cardio/__init__.py +3 -0
  6. pikobs/cardio/cardio.py +871 -0
  7. pikobs/cardio/cardio_plot.py +240 -0
  8. pikobs/cardio/cardio_plot_old.py +355 -0
  9. pikobs/configobs/__init__.py +8 -0
  10. pikobs/configobs/delete_folder.py +32 -0
  11. pikobs/configobs/families.py +161 -0
  12. pikobs/configobs/familyobs.py +152 -0
  13. pikobs/configobs/flags_criteria.py +191 -0
  14. pikobs/configobs/regionsobs.py +602 -0
  15. pikobs/configobs/type_boxes.py +47 -0
  16. pikobs/configobs/type_projection.py +238 -0
  17. pikobs/configobs/type_varno.py +278 -0
  18. pikobs/extension/color_mapping.json +26 -0
  19. pikobs/flags/__init__.py +4 -0
  20. pikobs/flags/flags.py +786 -0
  21. pikobs/flags/flags_count.py +77 -0
  22. pikobs/flags/flags_plot.py +292 -0
  23. pikobs/flags/flags_plot0.py +392 -0
  24. pikobs/flags/flags_plot3.py +207 -0
  25. pikobs/flags/flags_plotv2.py +590 -0
  26. pikobs/flags/plotpo.py +130 -0
  27. pikobs/flags/plotpo2.py +125 -0
  28. pikobs/flags/plotpo3.py +117 -0
  29. pikobs/flags/plotpo4.py +115 -0
  30. pikobs/flags/plotpo5.py +103 -0
  31. pikobs/flags/plotpo7.py +208 -0
  32. pikobs/flags/plotpo8.py +226 -0
  33. pikobs/flags/plotpo9.py +239 -0
  34. pikobs/histogram/__init__.py +2 -0
  35. pikobs/histogram/histogram.py +912 -0
  36. pikobs/histogram/histogram_plot.py +206 -0
  37. pikobs/mapobs/__init__.py +1 -0
  38. pikobs/mapobs/mapobs.py +1314 -0
  39. pikobs/obscountdb/__init__.py +3 -0
  40. pikobs/obscountdb/obscountdb.py +407 -0
  41. pikobs/obscountdb/obscountdb_old.py +725 -0
  42. pikobs/obscountdb/obscountdb_plot.py +451 -0
  43. pikobs/pikobsburp2db/__init__.py +2 -0
  44. pikobs/pikobsburp2db/pikobsburp2db.py +218 -0
  45. pikobs/profile/__init__.py +3 -0
  46. pikobs/profile/profile.py +2052 -0
  47. pikobs/profile/profile_plot.py +691 -0
  48. pikobs/progps/__init__.py +2 -0
  49. pikobs/progps/progps.py +2081 -0
  50. pikobs/progps2/__init__.py +2 -0
  51. pikobs/progps2/progps2.py +2089 -0
  52. pikobs/scatter/__init__.py +2 -0
  53. pikobs/scatter/scatter.py +1094 -0
  54. pikobs/scatter/scatter_plot.py +644 -0
  55. pikobs/scatter/scatter_plot_improved.py +428 -0
  56. pikobs/script/run_2exp.sh +22 -0
  57. pikobs/script/run_cardio.sh +25 -0
  58. pikobs/script/run_cardio_lco.sh +25 -0
  59. pikobs/script/run_cardio_sky.sh +25 -0
  60. pikobs/script/run_flag.sh +21 -0
  61. pikobs/script/run_histogra.sh +21 -0
  62. pikobs/script/run_mapobs.py +29 -0
  63. pikobs/script/run_obscountdb.sh +20 -0
  64. pikobs/script/run_pikobsburp2db.sh +48 -0
  65. pikobs/script/run_profile.sh +25 -0
  66. pikobs/script/run_profile_1.sh +26 -0
  67. pikobs/script/run_profile_radar.sh +25 -0
  68. pikobs/script/run_profile_s.sh +26 -0
  69. pikobs/script/run_progps.sh +35 -0
  70. pikobs/script/run_progps2.sh +35 -0
  71. pikobs/script/run_scatter.sh +23 -0
  72. pikobs/script/run_scatter_diff.sh +40 -0
  73. pikobs/script/run_scatter_one.sh +20 -0
  74. pikobs/script/run_scatter_two_sw.sh +40 -0
  75. pikobs/script/run_spatial.sh +28 -0
  76. pikobs/script/run_timeserie.sh +24 -0
  77. pikobs/script/run_timeserie_radar.sh +25 -0
  78. pikobs/script/run_vdedr.sh +21 -0
  79. pikobs/script/run_zone2.sh +33 -0
  80. pikobs/spatial/__init__.py +2 -0
  81. pikobs/spatial/spatial.py +1514 -0
  82. pikobs/timeserie/__init__.py +3 -0
  83. pikobs/timeserie/timeserie.py +687 -0
  84. pikobs/timeserie/timeserie_plot.py +453 -0
  85. pikobs/unittestpikobs/__init__.py +2 -0
  86. pikobs/unittestpikobs/test_pikobs.py +537 -0
  87. pikobs/unittestpikobs/unittest_timeserie.py +170 -0
  88. pikobs/vdedr/__init__.py +3 -0
  89. pikobs/vdedr/vdedr.py +932 -0
  90. pikobs/vdedr/vdedr_plot.py +292 -0
  91. pikobs/web/__init__.py +1 -0
  92. pikobs/web/viewer.py +491 -0
  93. pikobs/zone/__init__.py +2 -0
  94. pikobs/zone/zone.py +1298 -0
  95. pikobs/zone/zone_plot.py +669 -0
  96. pikobs-0.0.0.dist-info/METADATA +78 -0
  97. pikobs-0.0.0.dist-info/RECORD +100 -0
  98. pikobs-0.0.0.dist-info/WHEEL +5 -0
  99. pikobs-0.0.0.dist-info/entry_points.txt +16 -0
  100. pikobs-0.0.0.dist-info/top_level.txt +1 -0
pikobs/__init__.py ADDED
@@ -0,0 +1,19 @@
1
+ from .scatter import *
2
+ from .profile import *
3
+ from .configobs import *
4
+ from .cardio import *
5
+ from .timeserie import *
6
+ from .vdedr import *
7
+ from .extension import *
8
+ from .flags import *
9
+ from .unittestpikobs import *
10
+ from .zone import *
11
+ from .histogram import *
12
+ from .obscountdb import *
13
+ from .mapobs import *
14
+ from .progps import *
15
+ from .progps2 import *
16
+ from .pikobsburp2db import *
17
+ from .web import *
18
+ from .spatial import *
19
+
@@ -0,0 +1,79 @@
1
+ import matplotlib.pyplot as plt
2
+ import cartopy.crs as ccrs
3
+ import cartopy.feature as cfeature
4
+
5
+ def create_map(ax, Proj):
6
+ """
7
+ Create a map on a given axes with specific projection and features.
8
+
9
+ Parameters:
10
+ - ax (matplotlib.axes.Axes): Axes object to plot on.
11
+ - Proj (str): Projection type specifier.
12
+
13
+ Returns:
14
+ None
15
+ """
16
+ if Proj == 'cyl':
17
+ ax.set_extent([-180, 180, -90, 90], crs=ccrs.PlateCarree())
18
+ elif Proj in ['OrthoN', 'OrthoS']:
19
+ ax.set_global()
20
+ elif Proj == 'robinson':
21
+ ax.set_extent([-180, 180, -90, 90], crs=ccrs.PlateCarree())
22
+ elif Proj == 'Europe':
23
+ ax.set_extent([-20, 50, 30, 90], crs=ccrs.PlateCarree()) # Adjusted to center on Europe
24
+ elif Proj == 'Canada':
25
+ ax.set_extent([-150, -53, 42, 90], crs=ccrs.PlateCarree())
26
+ elif Proj == 'AmeriqueNord':
27
+ ax.set_extent([-140, -40, 20, 90], crs=ccrs.PlateCarree())
28
+ elif Proj == 'Npolar':
29
+ ax.set_extent([-180, 180, 0, 90], crs=ccrs.PlateCarree())
30
+ elif Proj == 'Spolar':
31
+ ax.set_extent([-180, 180, -90, 0], crs=ccrs.PlateCarree())
32
+ elif Proj == 'hrdps':
33
+ lat_0 = 48.8
34
+ delta_lat = 10.
35
+ lon_0 = 266.00
36
+ delta_lon = 40.
37
+ ax.set_extent([lon_0 - delta_lon, lon_0 + delta_lon, lat_0 - delta_lat, lat_0 + delta_lat], crs=ccrs.PlateCarree())
38
+
39
+ ax.add_feature(cfeature.OCEAN, facecolor='lightblue')
40
+ ax.add_feature(cfeature.LAND, edgecolor='black', facecolor='white') # Continents in white
41
+ ax.add_feature(cfeature.COASTLINE, linewidth=0.5)
42
+ ax.add_feature(cfeature.BORDERS, linewidth=0.5)
43
+ ax.add_feature(cfeature.LAKES, linewidth=0.5)
44
+
45
+ ax.set_title(Proj, fontsize=30) # Increase title font size
46
+ ax.gridlines(draw_labels=True)
47
+
48
+ projections = ['cyl', 'OrthoN', 'OrthoS', 'robinson', 'Europe', 'Canada', 'AmeriqueNord', 'Npolar', 'Spolar', 'hrdps']
49
+
50
+ # Create the figure and specific subplots for each projection
51
+ fig = plt.figure(figsize=(20, 10))
52
+
53
+ for idx, Proj in enumerate(projections):
54
+ if Proj == 'OrthoN':
55
+ ax = fig.add_subplot(2, 5, idx + 1, projection=ccrs.Orthographic(central_latitude=90.0, central_longitude=-80.0))
56
+ elif Proj == 'OrthoS':
57
+ ax = fig.add_subplot(2, 5, idx + 1, projection=ccrs.Orthographic(central_latitude=-90.0, central_longitude=-80.0))
58
+ elif Proj == 'robinson':
59
+ ax = fig.add_subplot(2, 5, idx + 1, projection=ccrs.Robinson())
60
+ elif Proj == 'Europe':
61
+ ax = fig.add_subplot(2, 5, idx + 1, projection=ccrs.NorthPolarStereo(central_longitude=10.0))
62
+ elif Proj == 'Canada':
63
+ ax = fig.add_subplot(2, 5, idx + 1, projection=ccrs.NorthPolarStereo(central_longitude=-105.0))
64
+ elif Proj in ['AmeriqueNord', 'Npolar']:
65
+ ax = fig.add_subplot(2, 5, idx + 1, projection=ccrs.NorthPolarStereo(central_longitude=-105.0))
66
+ elif Proj == 'Spolar':
67
+ ax = fig.add_subplot(2, 5, idx + 1, projection=ccrs.SouthPolarStereo(central_longitude=-86))
68
+ elif Proj == 'hrdps':
69
+ pole_latitude = 35.7
70
+ pole_longitude = 65.5
71
+ ax = fig.add_subplot(2, 5, idx + 1, projection=ccrs.RotatedPole(pole_latitude=pole_latitude, pole_longitude=pole_longitude))
72
+ else:
73
+ ax = fig.add_subplot(2, 5, idx + 1, projection=ccrs.PlateCarree())
74
+
75
+ create_map(ax, Proj)
76
+
77
+ plt.tight_layout()
78
+ plt.savefig('projections_map.png', bbox_inches='tight', dpi=300)
79
+
@@ -0,0 +1,104 @@
1
+ import pandas as pd
2
+ import sqlite3
3
+ import glob
4
+ from dask import delayed, compute
5
+ from dask.diagnostics import ProgressBar
6
+ from dask.distributed import Client
7
+
8
+ import pandas as pd
9
+ import sqlite3
10
+ import glob
11
+ from dask import delayed, compute
12
+ from dask.diagnostics import ProgressBar
13
+ from dask.distributed import Client
14
+
15
+ @delayed
16
+ def process_and_insert(file_path, new_db_filename, varno, criteria_id_stn, flag_criteria, latloncrit, vcocrit):
17
+ """
18
+ Procesa un archivo SQLite, calcula las métricas requeridas en pandas,
19
+ e inserta directamente los resultados en una tabla SQLite.
20
+ """
21
+ try:
22
+ # Procesar el archivo
23
+ with sqlite3.connect(file_path) as conn:
24
+ # Cargar datos desde las tablas
25
+ data = pd.read_sql_query("SELECT VCOORD,OMP,OMA,BIAS_CORR,VARNO, ID_OBS FROM data", conn)
26
+ header = pd.read_sql_query("SELECT DATE,ID_OBS,ID_STN FROM header", conn)
27
+
28
+ # Combinar las tablas
29
+ combined = pd.merge(header, data, on="ID_OBS", how='inner') # Ajusta según el esquema real
30
+
31
+ # Filtrar por VARNO y aplicar otros criterios
32
+ filtered = combined[
33
+ (combined["VARNO"] == varno) &
34
+ (combined["OMP"].notnull())
35
+ ]
36
+ # Aplicar criterios adicionales
37
+ if criteria_id_stn:
38
+ filtered = filtered.query(criteria_id_stn)
39
+ if flag_criteria:
40
+ filtered = filtered.query(flag_criteria)
41
+ if latloncrit:
42
+ filtered = filtered.query(latloncrit)
43
+ if vcocrit:
44
+ filtered = filtered.query(vcocrit)
45
+
46
+ # Calcular las métricas
47
+ grouped = filtered.groupby(["VCOORD", "ID_STN"]).agg(
48
+ DATE=("DATE", "first"), # O ajusta según sea necesario
49
+ Ntot=("OMP", "size"),
50
+ AvgOMP=("OMP", "mean"),
51
+ AvgOMA=("OMA", "mean"),
52
+ StdOMP=("OMP", "std"),
53
+ StdOMA=("OMA", "std"),
54
+ AvgBCOR=("BIAS_CORR", "mean")
55
+ ).reset_index()
56
+
57
+ grouped["VARNO"] = varno
58
+
59
+ # Insertar resultados en la base de datos SQLite
60
+ with sqlite3.connect(new_db_filename, uri=True, isolation_level=None, timeout=99999) as new_db_conn:
61
+ grouped.to_sql("serie_vdedr", new_db_conn, if_exists="append", index=False)
62
+ print(f"Procesado e insertado: {file_path}")
63
+
64
+ except Exception as e:
65
+ print(f"Error procesando {file_path}: {e}")
66
+
67
+
68
+ def process_files_and_insert(input_dir, new_db_filename, varno, criteria_id_stn="", flag_criteria="", latloncrit="", vcocrit=""):
69
+ """
70
+ Procesa todos los archivos en el directorio, calcula las métricas y las inserta directamente en SQLite.
71
+ """
72
+ sqlite_files = glob.glob(f"{input_dir}/*_cris")
73
+
74
+ # Crear tareas para procesar e insertar cada archivo
75
+ tasks = [
76
+ process_and_insert(file, new_db_filename, varno, criteria_id_stn, flag_criteria, latloncrit, vcocrit)
77
+ for file in sqlite_files
78
+ ]
79
+
80
+ # Ejecutar tareas en paralelo con ProgressBar
81
+ with ProgressBar():
82
+ compute(*tasks)
83
+
84
+
85
+ if __name__ == "__main__":
86
+ # Parámetros de entrada
87
+ input_directory = "/home/ata000/data_maestro/ppp5/maestro_archives/G2901H24_post/monitoring/banco/postalt/"
88
+ new_db_filename = "serie_vdedr.db"
89
+ varno = 12163 # Ejemplo de VARNO
90
+ criteria_id_stn = "ID_STN == 'NOAA20'"
91
+ flag_criteria = "" # Agrega tus criterios
92
+ latloncrit = "" # Agrega tus criterios
93
+ vcocrit = "" # Agrega tus criterios
94
+
95
+ # Configurar cliente Dask
96
+ with Client(processes=True, threads_per_worker=1, n_workers=40, silence_logs=40) as client:
97
+ print(client) # Muestra información del cliente
98
+ process_files_and_insert(
99
+ input_directory, new_db_filename, varno,
100
+ criteria_id_stn, flag_criteria, latloncrit, vcocrit
101
+ )
102
+
103
+
104
+