Spaces:
Sleeping
Sleeping
Update helpers/functional.py
Browse files- helpers/functional.py +13 -7
helpers/functional.py
CHANGED
|
@@ -140,16 +140,22 @@ def text_to_image(text, return_centre=False, return_gridcell=False, return_times
|
|
| 140 |
|
| 141 |
def cell_to_image(cell, return_centre=False, return_gridcell=False, return_timestamp=False, source='Sentinel-2 L2A'):
|
| 142 |
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
row = cell2row(cell, df, return_row = True)
|
| 150 |
-
|
| 151 |
if row is not None:
|
| 152 |
parquet_url, parquet_row, meta_row = row
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 153 |
|
| 154 |
try:
|
| 155 |
img = row2image(parquet_url, parquet_row)
|
|
|
|
| 140 |
|
| 141 |
def cell_to_image(cell, return_centre=False, return_gridcell=False, return_timestamp=False, source='Sentinel-2 L2A'):
|
| 142 |
|
| 143 |
+
try:
|
| 144 |
+
df = df_dict[source]
|
| 145 |
+
except:
|
| 146 |
+
# fallback to default (e.g. for metadata for AEF)
|
| 147 |
+
df = df_dict['Sentinel-2 L2A']
|
| 148 |
+
|
| 149 |
row = cell2row(cell, df, return_row = True)
|
| 150 |
+
|
| 151 |
if row is not None:
|
| 152 |
parquet_url, parquet_row, meta_row = row
|
| 153 |
+
year = int(meta_row.iloc[0].timestamp[:4])
|
| 154 |
+
|
| 155 |
+
# AEF is special - it's read live
|
| 156 |
+
if source == 'AlphaEarth Embeddings':
|
| 157 |
+
return cell_to_aef(cell, year, return_centre=return_centre, return_gridcell=return_gridcell, return_timestamp=return_timestamp)
|
| 158 |
+
|
| 159 |
|
| 160 |
try:
|
| 161 |
img = row2image(parquet_url, parquet_row)
|