Problem with extracting netcdf file

I am relatively new to python programming.i have downloaded a NetCDF file from IMD which contains Rainfall data. i want to extract the rainfall data for a particular coordinate … when i print it it shows dash line and mask (true and false value) it also shows fill value -999.0… how can see the rainfall values … need your help

Welcome!

Please don’t post screenshots of your code.

Instead, place your code and output in code blocks, like this:

```python
YOUR CODE HERE
```

(Or use the </> button on the toolbar)

In any case, rain is a netCDF variable, because you directly assigned such to the name. By contrast, with lat which you also printed, you first made a copy of it to a Numpy array (with [:]). When you print rain, it is only printing a truncated subset of the full data for that variable (note the ...s) which are at the edges of the full array, which are masked out (mask=True) and likely outside of the boundaries of the domain (otherwise, it would print a massive chunk of text to your console).

To explore your RAINFALL data, you can convert it to a Numpy array first, i.e.

rain = data.variables['RAINFALL'][:]

then, you should be able to browse the full array interactively in Spyder’s Variable Explorer (assuming it is an array).

To achieve what you’re specifically looking for, extracting rainfall data for a particular coord, you can first get the index of the lat and lon values closest to your desired coordinates, assuming you don’t already know it is in the data, and then just call something like data.variables['RAINFALL'][lon_idx, lat_idx] to get it.