Skip to content

Recommendations for creating a long vdslist quickly? #247

Answered by CRWayman
CRWayman asked this question in Q&A
Discussion options

You must be logged in to vote
import glob
import os
import time

import dask
import xarray as xr

from virtualizarr import open_virtual_dataset
from virtualizarr.kerchunk import FileType

monthlist = glob.glob('path/to/files/Y2024/M*')
monthlist.sort()

flist = []

m = 1

for month in monthlist[:1]:
    daylist = glob.glob(os.path.join(month,'D*'))
    daylist.sort()
    d = 1
    for day in daylist:
        hourlist = glob.glob(os.path.join(day, '*aqc*tavg*v1*'))
        hourlist.sort()
        flist += hourlist
        d += 1
    m += 1

num_files = len(flist)

flist = flist[:num_files]

dask_ovd = dask.delayed(open_virtual_dataset)
vds_lazy_list_local = [dask_ovd(f, filetype=FileType.netcdf4, indexes={}) for f in f…

Replies: 3 comments 6 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
6 replies
@CRWayman
Comment options

@CRWayman
Comment options

@TomNicholas
Comment options

@CRWayman
Comment options

Answer selected by TomNicholas
@CRWayman
Comment options

@TomNicholas
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants