shancx 1.9.33.227__py3-none-any.whl → 1.9.33.228__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.
shancx/Read.py CHANGED
@@ -55,30 +55,9 @@ result = getGrib(input_Path)
55
55
  import pygrib
56
56
  import numpy as np
57
57
  import pandas as pd
58
- import gzip
59
- import tempfile
60
- def readGrib(filepath, target_param=None):
61
- filepath= filepath
62
- if filepath.endswith('.gz'):
63
- with gzip.open(filepath, 'rb') as f:
64
- with tempfile.NamedTemporaryFile(suffix='.grib2', delete=False) as tmp:
65
- tmp.write(f.read())
66
- filepath = tmp.name
58
+ def readGrib(file_path, target_param=None):
67
59
  try:
68
- with pygrib.open(filepath) as grbs:
69
- if target_param:
70
- try:
71
- grb = grbs.select(shortName=target_param)[0]
72
- except:
73
- try:
74
- grb = grbs.select(parameterName=target_param)[0]
75
- except:
76
- raise ValueError(f"未找到参数: {target_param}")
77
- else:
78
- grb = grbs[1]
79
- data = grb.values
80
- lats, lons = grb.latlons()
81
- #data2
60
+ with pygrib.open(file_path) as grbs:
82
61
  field_info = []
83
62
  for grb in grbs:
84
63
  field_info.append({
@@ -91,6 +70,18 @@ def readGrib(filepath, target_param=None):
91
70
  'units': getattr(grb, 'units', 'N/A'),
92
71
  'shape': grb.values.shape
93
72
  })
73
+ if target_param:
74
+ try:
75
+ grb = grbs.select(shortName=target_param)[0]
76
+ except:
77
+ try:
78
+ grb = grbs.select(parameterName=target_param)[0]
79
+ except:
80
+ raise ValueError(f"未找到参数: {target_param}")
81
+ else:
82
+ grb = grbs[1]
83
+ data = grb.values
84
+ lats, lons = grb.latlons()
94
85
  return {
95
86
  'data': data,
96
87
  'lats': lats,
@@ -99,8 +90,7 @@ def readGrib(filepath, target_param=None):
99
90
  'parameterName': grb.parameterName,
100
91
  'level': grb.level,
101
92
  'validDate': grb.validDate,
102
- 'units': grb.units,
103
- "field_info":field_info
93
+ 'units': grb.units
104
94
  }
105
95
  }
106
96
  except Exception as e:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: shancx
3
- Version: 1.9.33.227
3
+ Version: 1.9.33.228
4
4
  Summary: A simple timer decorator
5
5
  Home-page: https://gitee.com/shancx
6
6
  Author: shancx
@@ -5,7 +5,7 @@ shancx/Lib.py,sha256=GUAspllSxk39mvj-F1Q8Ys0EcY_lQfZPRGPE7L3x4SE,977
5
5
  shancx/Path1.py,sha256=vX4A5RgdwVyIVVNZRocl18rOu1Z8YMLfDb0B92-0bE8,5334
6
6
  shancx/Point.py,sha256=gyIomOVbNoz6SOcAhhTS26NHBeJ0TOwB-ljNsBWN1ZE,1909
7
7
  shancx/QC.py,sha256=MFxbPMEwrnk5l0sTFMrx13wPlXJ5WI5TovzaiBoEr0E,9848
8
- shancx/Read.py,sha256=94FNUWiZn71X6ArZhyqhyORNcWJffC7Hz76BAtF9CJc,4577
8
+ shancx/Read.py,sha256=OCSiKbt_yIFFUWSDy6T83KlOYYMHOP628aXpatQCkjw,4197
9
9
  shancx/Resize.py,sha256=uwiOhD-aWPDLvIwOYEX-XXN_suOXv6hPDcaGyr4JLC4,4044
10
10
  shancx/ZR.py,sha256=5APchqVoI1G2MkrN9YJSWCwfLUygcSFIsUXSo9aq1Qg,341
11
11
  shancx/__init__.py,sha256=6sfiHElECqfy5eEEGqaCAw4YiKxgKfJ5IFFh9yvtewk,11442
@@ -87,7 +87,7 @@ shancx/Train/multiGpu.py,sha256=D_oZeiSc7VWktpnVDwrFOC1CYZSt9rxOKY5lngE5vFg,820
87
87
  shancx/Train/prepare.py,sha256=vL_8UOA66oZCBIwCICtihsGibivtNgaVJGulJxfNdn8,6793
88
88
  shancx/Train/renet50.py,sha256=wEhYk1X96WE5zuqHqVxWLJa-A5jDNkz4z6edORNufnA,6428
89
89
  shancx/tensBoard/__init__.py,sha256=ga2C5YyJITvvQA1ocpxna_KNFnNRJVwkTjLoIglLZUQ,993
90
- shancx-1.9.33.227.dist-info/METADATA,sha256=2IF7Rl9DDL9BPZypQ0PtDTid3CfYF7wOu9HjWhQO42Y,850
91
- shancx-1.9.33.227.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
92
- shancx-1.9.33.227.dist-info/top_level.txt,sha256=akfCS1vKWz3pNmEN_yN9ZiGp-60IQY5ET38mRx_i_-4,7
93
- shancx-1.9.33.227.dist-info/RECORD,,
90
+ shancx-1.9.33.228.dist-info/METADATA,sha256=r6Ia88MeKIEh1e5RlSm2UzxuC7QwY_dJInPIr5iE8gU,850
91
+ shancx-1.9.33.228.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
92
+ shancx-1.9.33.228.dist-info/top_level.txt,sha256=akfCS1vKWz3pNmEN_yN9ZiGp-60IQY5ET38mRx_i_-4,7
93
+ shancx-1.9.33.228.dist-info/RECORD,,