'How to make a square array dataset on polar stereo-graphic projection from general lat-lon gridded netCDF dataset?

I would like to convert shape of dataset from general lat-lon girdded netCDF dataset to a square array on the polar stereographic projection for making training dataset for a deep learning project (Figure 1 might help you understand the question). However, I still can't figure out how to do this.. it's been over a month.

Format of dataset I have and desired shape of the dataset pix1

First I tried making a polar stereographic plot using cartopy and matplotlib and extract array from it. So I was able to make this plot (figure 2) but extracting the square array from the figure was impossible.

I thought about just making image dataset by saving generate plots but exact number of the dataset is very important so I could not just use image dataset.

A heatmap of geopotential height on the polar stereographic projection pix2

I would greatly apprecitate for providing any ideas for this problem.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source