I'm trying to create GIFs for every variable in a NetCDF file using the time dimension.
filepath = 'foam.nc'
variables = getVariables(filepath)
lat = getValue('lat', variables)[:]
lon = getValue('lon', variables)[:]
for var in keys:
createGif(entity, lat, lon, t)
This works, but the process is taking a very long time (250 seconds). This NetCDF file contains 4 dimensions (time, hybrid, lat, long) with time having 9 depths.
Using the following example: https://stackoverflow.com/a/28463266/8166528 and https://stackoverflow.com/a/28975239/8166528, I tried to speed up the process using pool.map by giving every "createGif" a different thread, but I can't get it to work.
What I've tried:
entities = []
lats = []
lons = []
ts = []
for var in keys:
entity = getValue(var, variables)
entities.append(entity)
lats.append(lat)
lons.append(lon)
ts.append(t)
pool = ThreadPool(8)
results = pool.starmap(createGif, zip(entities, lats, lons, ts))
pool.close()
pool.join()
Can someone point me in the right direction?