It’s a little tricky to figure out what’s happening if we can’t run your code. It looks like you have given us almost a complete script but some variables like num_lat and num_lon are missing. Can you provide a completely runnable version of this snippet?