if Province is not np.nan: place += Province + '\n' if Country is not np.nan: place += Country + '\n' data.append([place, theta, phi, confirmed, deaths, recos]) data.append(['U.S.A.\n', 0.9, 1.4, conf_us, deat_us, reco_us]) return (date, data, csvdata['Confirmed'].sum(), csvdata['Deaths'].sum(), csvdata['Recovered'].sum()) # ------------------------------------------------------------------------- # Create the scene: from vedo import spher2cart, Sphere, Text2D, Earth, merge, show date, data, allconf, alldeat, allreco = load_data() s1, s2, vigs = [], [], [] for place, theta, phi, confirmed, deaths, recos in data: pos = spher2cart(1, theta, phi) fl = 'cases: ' + str(confirmed) + '\ndeaths: ' + str(deaths) radius = np.power(confirmed, 1 / 3) / 2000 sph1 = Sphere(pos, radius, alpha=0.4, res=12).flag(place + fl) if deaths > 5000: sph1.flag(fl) anchorpt = sph1.pos() * (1 + radius) vig = sph1.vignette(place, anchorpt, font="Kanopus") vig.c('k').scale(1.5 * (1 + radius)).followCamera() vigs.append(vig) s1.append(sph1) s2.append( Sphere(pos, np.power(deaths, 1 / 3) / 2000, alpha=0.4, c='k', res=10)) tx = Text2D('COVID-19 spread on ' + date + '\n# cases : ' + str(allconf) + '\n# deaths: ' + str(alldeat) + '\n# recovd: ' + str(allreco) +
N = 50 # number of grid intervals on the unit sphere rmax = 1.5 # line length x0 = [0, 0, 0] # set object at this position ############################################################# shape = load(datadir + 'apple.ply').normalize().pos(x0).lineWidth(0.1) show(shape, at=0, N=2, axes=dict(zxGrid=False)) ############################################################ # cast rays from the center and find intersections agrid, pts = [], [] for th in np.linspace(0, np.pi, N, endpoint=False): lats = [] for ph in np.linspace(0, 2 * np.pi, N, endpoint=False): p = spher2cart(rmax, th, ph) intersections = shape.intersectWithLine([0, 0, 0], p) if len(intersections): value = mag(intersections[0]) lats.append(value) pts.append(intersections[0]) else: lats.append(rmax) pts.append(p) agrid.append(lats) agrid = np.array(agrid) grid = pyshtools.SHGrid.from_array(agrid) clm = grid.expand() grid_reco = clm.expand(lmax=lmax) # cut "high frequency" components