@@ -289,8 +289,8 @@ def _find_summary_from_csw(search_fname, forecast_time, scheme, netloc):
289
289
return summary_text
290
290
291
291
def _size_x_y (xr_dataset ):
292
- x_l = ['x' , 'X' , 'Xc' , 'longitude' , 'lon' ]
293
- y_l = ['y' , 'Y' , 'Yc' , 'latitude' , 'lat' ]
292
+ x_l = ['x' , 'X' , 'Xc' , 'xc' , ' longitude' , 'lon' ]
293
+ y_l = ['y' , 'Y' , 'Yc' , 'yc' , ' latitude' , 'lat' ]
294
294
for x ,y in zip (x_l , y_l ):
295
295
try :
296
296
return xr_dataset .dims [x ], xr_dataset .dims [y ]
@@ -311,11 +311,9 @@ def _fill_metadata_to_mapfile(orig_netcdf_path, forecast_time, map_object, schem
311
311
summary_cache [bn ] = "Not Available."
312
312
map_object .web .metadata .set ("wms_title" , wms_title )
313
313
map_object .web .metadata .set ("wms_onlineresource" , f"{ scheme } ://{ netloc } /api/get_quicklook{ orig_netcdf_path } " )
314
- map_object .web .metadata .set ("wms_srs" , "EPSG:3857 EPSG:3978 EPSG:4269 EPSG:4326 EPSG:25832 EPSG:25833 EPSG:25835 EPSG:32632 EPSG:32633 EPSG:32635 EPSG:32661" )
314
+ map_object .web .metadata .set ("wms_srs" , "EPSG:3857 EPSG:3978 EPSG:4269 EPSG:4326 EPSG:25832 EPSG:25833 EPSG:25835 EPSG:32632 EPSG:32633 EPSG:32635 EPSG:32661 EPSG:3575 " )
315
315
map_object .web .metadata .set ("wms_enable_request" , "*" )
316
316
map_object .setProjection ("AUTO" )
317
- _x , _y = _size_x_y (xr_dataset )
318
- map_object .setSize (_x , _y )
319
317
320
318
# try:
321
319
# map_object.setSize(xr_dataset.dims['x'], xr_dataset.dims['y'])
@@ -345,6 +343,11 @@ def _fill_metadata_to_mapfile(orig_netcdf_path, forecast_time, map_object, schem
345
343
except KeyError :
346
344
logger .debug ("Could not detect extent of dataset. Force full Earth." )
347
345
map_object .setExtent (- 180 , - 90 , 180 , 90 )
346
+
347
+ # Need to set size of map object after extent is set
348
+ _x , _y = _size_x_y (xr_dataset )
349
+ logger .debug (f"x and y dimensions in dataset { _x } { _y } " )
350
+ map_object .setSize (_x , _y )
348
351
return
349
352
350
353
def _find_projection (ds , variable , grid_mapping_cache ):
@@ -368,16 +371,15 @@ def _find_projection(ds, variable, grid_mapping_cache):
368
371
369
372
def _extract_extent (ds , variable ):
370
373
"""Extract extent of variable."""
371
- x_l = ['x' , 'X' , 'Xc' , 'longitude' , 'lon' ]
372
- y_l = ['y' , 'Y' , 'Yc' , 'latitude' , 'lat' ]
374
+ x_l = ['x' , 'X' , 'Xc' , 'xc' , ' longitude' , 'lon' ]
375
+ y_l = ['y' , 'Y' , 'Yc' , 'yc' , ' latitude' , 'lat' ]
373
376
for x , y in zip (x_l , y_l ):
374
377
try :
375
378
376
379
ll_x = min (ds [variable ].coords [x ].data )
377
380
ur_x = max (ds [variable ].coords [x ].data )
378
381
ll_y = min (ds [variable ].coords [y ].data )
379
382
ur_y = max (ds [variable ].coords [y ].data )
380
- print (ds [variable ].coords [x ])
381
383
return ll_x ,ur_x ,ll_y ,ur_y
382
384
except KeyError :
383
385
pass
@@ -536,6 +538,10 @@ def _generate_getcapabilities(layer, ds, variable, grid_mapping_cache, netcdf_fi
536
538
ll_x , ur_x , ll_y , ur_y = _extract_extent (ds , variable )
537
539
logger .debug (f"ll_x, ur_x, ll_y, ur_y { ll_x } { ur_x } { ll_y } { ur_y } " )
538
540
layer .setProjection (grid_mapping_cache [grid_mapping_name ])
541
+ if "units=km" in grid_mapping_cache [grid_mapping_name ]:
542
+ layer .units = mapscript .MS_KILOMETERS
543
+ elif "units=m" in grid_mapping_cache [grid_mapping_name ]:
544
+ layer .units = mapscript .MS_METERS
539
545
layer .status = 1
540
546
layer .data = f'NETCDF:{ netcdf_file } :{ variable } '
541
547
layer .type = mapscript .MS_LAYER_RASTER
@@ -564,7 +570,7 @@ def _generate_getcapabilities(layer, ds, variable, grid_mapping_cache, netcdf_fi
564
570
# logger.debug("Could not use time_coverange_start global attribute. wms_timeextent is not added")
565
571
566
572
for dim_name in ds [variable ].dims :
567
- if dim_name in ['x' , 'X' , 'Xc' , 'y' , 'Y' , 'Yc' , 'longitude' , 'latitude' , 'lon' , 'lat' ]:
573
+ if dim_name in ['x' , 'X' , 'Xc' , 'xc' , ' y' , 'Y' , 'Yc' , 'yc ' , 'longitude' , 'latitude' , 'lon' , 'lat' ]:
568
574
continue
569
575
logger .debug (f"Checking dimension: { dim_name } " )
570
576
if dim_name in 'time' :
@@ -629,7 +635,6 @@ def _generate_getcapabilities(layer, ds, variable, grid_mapping_cache, netcdf_fi
629
635
style1 .rangeitem = 'pixel'
630
636
style1 .mincolor = mapscript .colorObj (red = 0 , green = 0 , blue = 0 )
631
637
style1 .maxcolor = mapscript .colorObj (red = 255 , green = 255 , blue = 255 )
632
-
633
638
return True
634
639
635
640
def _generate_getcapabilities_vector (layer , ds , variable , grid_mapping_cache , netcdf_file , direction_speed = False , last_ds = None , netcdf_files = [], product_config = None ):
@@ -679,7 +684,7 @@ def _generate_getcapabilities_vector(layer, ds, variable, grid_mapping_cache, ne
679
684
except Exception :
680
685
logger .debug ("Could not use time_coverange_start global attribute. wms_timeextent is not added" )
681
686
for dim_name in ds [variable ].dims :
682
- if dim_name in ['x' , 'X' , 'Xc' , 'y' , 'Y' , 'Yc' , 'longitude' , 'latitude' , 'lon' , 'lat' ]:
687
+ if dim_name in ['x' , 'X' , 'Xc' , 'xc' , ' y' , 'Y' , 'Yc' , 'yc ' , 'longitude' , 'latitude' , 'lon' , 'lat' ]:
683
688
continue
684
689
if dim_name in 'time' :
685
690
logger .debug ("handle time" )
@@ -758,7 +763,7 @@ def _find_dimensions(ds, actual_variable, variable, qp, netcdf_file, last_ds):
758
763
# Find available dimension not larger than 1
759
764
dimension_search = []
760
765
for dim_name in ds [actual_variable ].dims :
761
- if dim_name in ['x' , 'X' , 'Xc' , 'y' , 'Y' , 'Yc' , 'longitude' , 'latitude' , 'lon' , 'lat' ]:
766
+ if dim_name in ['x' , 'X' , 'Xc' , 'xc' , ' y' , 'Y' , 'Yc' , 'yc ' , 'longitude' , 'latitude' , 'lon' , 'lat' ]:
762
767
continue
763
768
for _dim_name in [dim_name , f'dim_{ dim_name } ' ]:
764
769
if _dim_name == 'height' or _dim_name == 'dim_height' :
@@ -975,6 +980,10 @@ def _generate_layer(layer, ds, grid_mapping_cache, netcdf_file, qp, map_obj, pro
975
980
976
981
set_scale_processing_key = False
977
982
layer .setProjection (grid_mapping_cache [grid_mapping_name ])
983
+ if "units=km" in grid_mapping_cache [grid_mapping_name ]:
984
+ layer .units = mapscript .MS_KILOMETERS
985
+ elif "units=m" in grid_mapping_cache [grid_mapping_name ]:
986
+ layer .units = mapscript .MS_METERS
978
987
layer .status = 1
979
988
if variable .endswith ('_vector' ) or variable .endswith ("_vector_from_direction_and_speed" ):
980
989
@@ -1321,7 +1330,7 @@ def _generate_layer(layer, ds, grid_mapping_cache, netcdf_file, qp, map_obj, pro
1321
1330
min_val = np .nanmin (ds [actual_variable ][:,:].data )
1322
1331
max_val = np .nanmax (ds [actual_variable ][:,:].data )
1323
1332
elif len (dimension_search ) == 1 :
1324
- logger .debug ("Len 1" )
1333
+ logger .debug (f "Len 1 of { actual_variable } " )
1325
1334
min_val = np .nanmin (ds [actual_variable ][dimension_search [0 ]['selected_band_number' ],:,:].data )
1326
1335
max_val = np .nanmax (ds [actual_variable ][dimension_search [0 ]['selected_band_number' ],:,:].data )
1327
1336
if '_FillValue' in ds [actual_variable ].attrs :
0 commit comments