I am trying to display a netCDF file that I obtained from NOAA in ArcMap. However, it keeps crashing ArcMap. I have used precipitation netCDFs from NWS before with no issues.
The netCDF is just a sample they sent me of many netCDF files they will start making available as part of a new lightning data release. So I would like to write a script that corrects the netCDF files.
They told me there are "some issues with data formatting (e.g., unsigned integers for event lat and lon) and that it won't be fixed for some time."
I used the following code to open the netCDF to look at the data. I only included the coordinates output and not the data variables and attributes.
xr.open_dataset('C:\\lightning\\sample.nc' <xarray.Dataset> Dimensions: (number_of_events: 5879, number_of_field_of_view_bounds: 2, number_of_flashes: 687, number_of_groups: 3454, number_of_time_bounds: 2, number_of_wavelength_bounds: 2) Coordinates: event_id (number_of_events) int32 -940849349 ... event_time_offset (number_of_events) datetime64[ns] 2017-09-08T19:30:19.917000 ... event_lat (number_of_events) float64 -1.687 ... event_lon (number_of_events) float64 -188.5 ... event_parent_group_id (number_of_events) int32 1324574251 ... group_id (number_of_groups) int32 1324574251 ... group_time_offset (number_of_groups) datetime64[ns] 2017-09-08T19:30:19.834000 ... group_lat (number_of_groups) float32 -1.68695 ... group_lon (number_of_groups) float32 -55.3391 ... group_parent_flash_id (number_of_groups) int16 12590 ... flash_id (number_of_flashes) int16 12590 ... flash_time_offset_of_first_event (number_of_flashes) datetime64[ns] 2017-09-08T19:30:19.834000 ... flash_time_offset_of_last_event (number_of_flashes) datetime64[ns] 2017-09-08T19:30:19.834000 ... flash_lat (number_of_flashes) float32 -1.68695 ... flash_lon (number_of_flashes) float32 -55.3391 ... product_time datetime64[ns] 2017-09-08T19:30:20 lightning_wavelength float32 777.4 group_time_threshold float32 0.0 flash_time_threshold float32 3.33 lat_field_of_view float32 0.0 lon_field_of_view float32 -89.5
I then used np.savetxt to save event_lat, event_lon, group_lat, and group_lon to CSV files so I could ananlyze the coordinates.
What I found was that group_lat values ranged from 42 to -51 and group_lon values range from -44 to -142. These are correct because the file is supposed to display data from North and South America and parts of adjacent oceans.
But, event_lat values ranged from -0.03 to -133 and event_lon values ranged from -90.2 to -222.29. Looking at event_lat CSV, there is a chunk of data that ranged from -.03 to -51 (this should be data for southern hemisphere) and a chunk of data ranging from -90.5 to -132 (this should be the northern hemisphere data). However, that range should actually be 0.5 to 42 latitude.
I'm not sure what's going on with the event_lon data. -90 to -142 coordinates look similar between event_lon and group_lon, so I think that is fine. However, event_lon also has data ranging from -177 to -222 and no data greater than -90. The group_lon data ranges from -44 to -142.5.
Is there a way I can fix these files with python?