Questions tagged [python-iris]

Iris seeks to provide a powerful, easy to use, and community-driven Python library for analysing and visualising meteorological and oceanographic data sets. NOTE: This is not the tag to use if your question relates to the common Iris dataset (often relating to machine learning). This tag is for the tool found at https://github.com/scitools/iris

With Iris you can:

  • Use a single API to work on your data, irrespective of its original format.
  • Read and write (CF-)netCDF, GRIB, and PP files.
  • Easily produce graphs and maps via integration with matplotlib and cartopy.

Visit https://scitools-iris.readthedocs.io/en/latest/ for the latest documentation.

74 questions
1
vote
0 answers

Find parameter in GRIB with iris

New user of Iris here. I have loaded a GRIB file that has created a list of cubes, many of them have "unknown" name and units. In this list of cubes there should be the temperature at different model levels (perhaps in not all the cubes). Example of…
David
  • 1,155
  • 1
  • 13
  • 35
1
vote
1 answer

How would I extract a region of some NEMO ocean model output in Iris?

Is there a straightforward way to extract a region from an Iris cube which is described by 2D latitude and longitude variables, for example using NEMO ocean model data? I found this workaround but was wondering if there was a way to do this in…
jonnyhtw
  • 61
  • 8
1
vote
0 answers

Changing values in iris cube based on coordinates instead of index

I would like to be able to change values in iris based on the coordinate, instead of the index. For example, consider the following cube and say that I wish to set values from -45N to 45N and 160E to 240E to 1: import iris import numpy as np from…
chuaxr
  • 188
  • 1
  • 7
1
vote
1 answer

calculating some seasonal climate metrics with Iris

I have a new project on, calculating some seasonal climate metrics. As part of this, I need to identify, eg the wettest quarter in a set of climatological monthly data: print(pr_cube) Precipitation / (mm) (time: 12; latitude: 125;…
RBodman
  • 13
  • 4
1
vote
1 answer

What am I doing wrong? TypeError: unsupported operand type(s) for -: 'str' and 'Cube'

I am having some problems with my code for my MSc thesis. I am following https://github.com/ErikaWarnatzsch/Malawi-Future-Climate-Modelling-Assessment/edit/master/Histogram_TasMAX.py model to be able to build a Histogram for future RCP scenarios…
1
vote
1 answer

how to categorize lat/lon to find nearest city

I am playing with iris (really neat!) and I have a list of cities lat/lons I am interested to see average temperature over time. I have netcdf files with air temperatures covering entire country. I would like to tag data points in a cube with…
mishkin
  • 5,932
  • 8
  • 45
  • 64
1
vote
0 answers

How to parallelize a workflow that includes multiprocessing and multithreading aspects

I have a workflow that I want to parallelize with dask, but am struggling to find an effective way to do so. I have profiled the code and identified the aspects that I want to speed up. Here it is in psuedocode: for i in range(n): x =…
tcrocker
  • 11
  • 2
1
vote
0 answers

Converting NetCDF to grib2: problem in save in grib2 format

I'm using Iris module to convert from netcdf to grib2: import iris cubes = iris.load('SST.nc') # each variable in the netcdf file is a…
1
vote
1 answer

Reading a grib2 message into an Iris cube

I am currently exploring the notion of using iris in a project to read forecast grib2 files using python. My aim is to load/convert a grib message into an iris cube based on a grib message key having a specific value. I have experimented with…
Xav
  • 53
  • 7
1
vote
2 answers

Splitting data set into training and test data, keeping the ratio

I have the Iris data set (Can be found here: https://www.kaggle.com/uciml/iris ), which I should split into a test and a training set. However, I need to split it so that the class distribution in the training and test set is the same as in the…
user10411263
  • 49
  • 3
  • 10
1
vote
1 answer

"unfair" pandas categorical.from_codes

I have to assign a label to categorical data. Let us consider the iris example: import pandas as pd import numpy as np from sklearn.datasets import load_iris iris = load_iris() print "targets: ", np.unique(iris.target) print "targets: ",…
Andrea Ianni
  • 829
  • 12
  • 24
1
vote
2 answers

Time variable units "day as %Y%m%d.%f" in python iris

I am hoping someone can help. I am running a few climate models (NetCDF files) in python using iris. All was working well until I added my last model which is formatted differently. The units they use for the time variable in the new models is day…
ErikaAWT
  • 67
  • 2
  • 14
1
vote
1 answer

Using cube.interpolate to go from theta levels to rho levels

I have a cube of temperatures on theta levels and I need a cube of temperatures on rho levels. Is cube.interpolate able to do this, or do I need something else? The vertical regridding example in the Iris user guide has an example of going from…
1
vote
1 answer

Combine Iris constraints with OR?

The Iris user guide gives lots of info about combining constraints on coordinates with a logical AND. Is it also possible to combine them with a logical OR? I want to extract parts of a cube where (coord1 == x AND coord2 == y) OR (coord1 ==…
RuthC
  • 1,269
  • 1
  • 10
  • 21
1
vote
1 answer

Setting all values in a cube more than a certain number to zero

I'm trying to set all values in a cube more than a certain number to zero. I've tried the following noddy way: cube_tot_lo.data = np.where(cube_tot_lo.data < 1.0e19, cube_tot_lo.data, 0.0) but it is a large cube and kills the memory. I was…
Bosley
  • 11
  • 2