遥感数据并行运算(satellite remote sensing data parallell processing)

文章内容仅用于自己知识学习和分享,如有侵权,还请联系并删除 :)

之前不太会用,单纯想记录一下,后面或许还会用到

1. 教程

[1] Pleasingly Parallel Programming: link

1.1 处理器,核和线程 Processors (CPUs), Cores, and Threads

  • Microprocessor: an integrated circuit that contains the data processing logic and control for a computer.

  • Multi-core processor: a microprocessor containing multiple processing units (cores) on a single integrated circuit. Each core in a multi-core processor can execute program instructions at the same time.

  • Process: an instance of a computer program (including instructions, memory, and other resources) that is executed on a microprocessor.

  • Thread: a thread of execution is the smallest sequence of program instructions that can be executed independently, and is typically a component of a process. The threads in a process can be executed concurrently and typically share the same memory space. They are faster to create than a process.

  • Cluster: a set of multiple, physically distinct computing systems, each with its own microprocessors, memory, and storage resources, connected together by a (fast) network that allows the nodes to be viewed as a single system.

在这里插入图片描述

1.2 Parallelization with Dask

主要看了Dask

1.2.1 Dask简介

[2] Dask python库官方安装和使用教程: link
[3] 中文 掘金: dask介绍: link (介绍了chunk)
[4] 中文 腾讯:Python 数据科学 Dask.array:并行计算的利器: link
[5] 中文 风中飞舞:Dask教程 数组: link (这个讲dask array和numpy array的区别,以及chunk讲的很好)

  1. 定义: Dask is a tool that helps us easily extend our familiar python data analysis tools to medium and big data, i.e. dataset that can’t fit in our computer’s RAM. In many cases, dask also allows us to speed up our analysis by using mutiple CPU cores. Dask can help us work more efficiently on our laptop, and it can also help us scale up our analysis on HPC and cloud platforms. Most importantly, dask is almost invisible to the user, meaning that you can focus on your science, rather than the details of parallel computing.

  2. 数据结构: 目前dask支持5种主要的数据结构,目前dask支持5种主要的数据结构,分别是

  • Array(用于存放类numpy的多维数组),
  • DataFrame(不用多说,类pandas的二维表结构的数据帧),
  • Bag(更简单的一个数组),
  • Delayed(对函数的异步处理封装,针对本地多进程与多线程),
  • Futures(对函数的分布式异步提交处理封装,比delayed多提供网络api)

在这里插入图片描述

1.2.2 Dask和array

[3] 中文 掘金: dask介绍: link (介绍了chunk)
[4] 中文 腾讯:Python 数据科学 Dask.array:并行计算的利器: link
[5] 中文 风中飞舞:Dask教程 数组: link (这个讲dask array和numpy array的区别,以及chunk讲的很好)
[6] 地学格网数据处理: Computing with Dask: link (讲的很详细)
[7] 地学格网数据处理: Basics of Xarray with Dask Parallization for Earth Data: link
[8] 地学格网数据处理 : An Introduction to Earth and Environmental Data Science: link

  1. 为什么Dask array运算效率会比较高 ?

    其实dask并没有真正的把所有分块后的数据读入内存,只是在内存中存放了一个指针,该指针指向了这些数据块,这里涉及一个重要概念–Delayed(延迟计算) [3]

    Dask.array的核心设计思想之一是将数组拆分成小块,并使用延迟计算的方式执行操作。这种分块策略有以下几个优势 [4] :

    • 处理大规模数据:将数据拆分成小块,可以使Dask.array处理比内存更大的数据集。每个小块可以在内存中处理,从而有效地利用计算资源。

    • 并行计算:Dask.array可以利用多核或分布式系统来并行执行计算。每个小块可以在不同的处理器上并行计算,从而加快计算速度。

    • 节约资源:Dask.array只在需要时执行计算,避免了一次性加载整个数组到内存中,节约了内存和计算资源

补充 [6]: Dask array的区别和 numpy array的不同,调用前不占空间, 直到we call .compute() on a dask array, the computation is trigger and the dask array becomes a numpy array.

补充[6]: chunk的概念
The dask array representation reveals the concept of “chunks”. “Chunks” describes how the array is split into sub-arrays. We did not specify any chunks, so Dask just used one single chunk for the array. This is not much different from a numpy array at this point.

补充[8]: 关于Distributed Clusters 分布式集群一个常见的错误是过早使用分布式模式。对于较小的数据,分布式实际上比默认的多线程调度程序或根本不使用 Dask 要慢得多。只有当数据远大于计算机内存所能处理的容量时,才应该使用分布式。

  1. 案例讲解
  • [6] Computing with Dask: link (讲的很详细)

1.2.3 Dask和xarray

dask和xarry和rioxarray结合可以更高效的处理遥感数据

  • xarray 和dask的关系: Almost all of xarray’s built-in operations work on Dask arrays.
    link

  • rioxarray 和dask的关系: rioxarray extends xarray with the rio accessor, which stands for “raster input and output. link

[7] 地学格网数据处理: Basics of Xarray with Dask Parallization for Earth Data: link
[8] 地学格网数据处理 : An Introduction to Earth and Environmental Data Science: link
[9] 地学格网数据处理 : link (xarray函数中没有自己想要的)

作者主要介绍了了处理地学数据并行运算两种情况: computation which is easily iterable over multiple files和computation which is not easily iterable over multiple files.

  1. A computation which simply needs to be replicated many times, such as applying the same computation to 1000 files. 对每个文件的操作都一样

    The first schematic (below) shows an example for a common NASA Earthdata set format, where each file contains data for one timestamp, as well as spatial dimensions such as x1=latitude, x2=longitude. We want to apply a function F(x1,x2) to each file.

    Alternately, each file could correspond to a satellite orbit, and x1, x2 are the satellite cross-track and along-track dimensions.

在这里插入图片描述

  1. A computation which cannot trivially be replicated over multiple files, or over parts of a single file. 需要同时读取多个文件再处理

    In the example of the NASA Earthdata set, where each file corresponds to a separate time stamp, this type of parallelization challenge could correspond to taking the mean and standard deviation over time at each latitude, longitude grid point (second schematic below).

    In this case, data from all the files is required to compute these quantities.

    Another example is an empirical orthogonal function (EOF) analysis, which needs to be performed on the entire 3D dataset as it extracts key modes of variability in both the time and spatial dimensions (third schematic).

在这里插入图片描述


================结合链接[7]理解============
================结合链接[7]理解============
import dask
from dask.distributed import Client, LocalCluster


# 1. 不够快
%%time 
#sstdata['analysed_sst'].mean(dim='time').compute() # Un-comment to test computation time.  


# 2. 调用Clinent函数
# client = Client()
Client(n_workers=2, threads_per_worker=2, memory_limit='1GB'):

# 参数含义:
n_workers=2: This tells the system to use 2 separate computers or cores to run your computations. 计算机的核。

threads_per_worker=2: This tells each of the 2 computers or cores to use 2 separate "threads" (or parts) to run 

the computations. This allows the computations to be split up and run in parallel, which can make them faster.
memory_limit='1GB': This tells the system to limit the amount of memory that each of the 2 computers or cores can use to 1 gigabyte (GB). This can be useful to prevent the system from using too much memory and slowing 
down.

# 3. 调用后速度变快
%%time
meansst_2dmap = sstdata['analysed_sst'].mean(dim='time').compute()

  1. 补充案例:并行运算时候,xarray函数中没有自己想要的函数,解决方法 [9] link

Custom workflows and automatic parallelization

方法1: Almost all of xarray’s built-in operations work on Dask arrays. If you want to use a function that isn’t wrapped by xarray, one option is to extract Dask arrays from xarray objects (.data) and use Dask directly.

方法2: Another option is to use xarray’s apply_ufunc() function, which can automate embarrassingly parallel “map” type operations where a function written for processing NumPy arrays should be repeatedly applied to xarray objects containing Dask arrays. It works similarly to dask.array.map_blocks() and dask.array.blockwise(), but without requiring an intermediate layer of abstraction.

一些想法:

提高代码的运行效率主要从两个维度出发:减小内存占用和并行。

  • dask: 先考虑读入数据内存占用。 dask数据结构的好处: dask array和 xarray只有调用的时候值得时候才会占用内存,这是其相对于numpy的好处,会减小内存的占用。

  • dask+ parallel: 再考虑如何提高计算效率,计算效率可以结合并行。但是如果想让速度更快,还是得用并行,并行的方法可以直接调用dask库,或者参考[9] link

参考文献

[1] Pleasingly Parallel Programming: link

[2] Dask python库官方安装和使用教程: link

[3] 中文 掘金: dask介绍: link (介绍了chunk)

[4] 中文 腾讯:Python 数据科学 Dask.array:并行计算的利器: link

[5] 中文 风中飞舞:Dask教程 数组: link (这个讲dask array和numpy array的区别,以及chunk讲的很好)

[6] 地学格网数据处理:Computing with Dask: link (Dask array 讲的很详细)

[7] 地学格网数据处理:Basics of Xarray with Dask Parallization for Earth Data: link

[8] 地学格网数据处理 : An Introduction to Earth and Environmental Data Science: link

[9] 地学格网数据处理 : link (xarray函数中没有自己想要的, 解决方法)

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mfbz.cn/a/754038.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

使用容器部署redis_设置配置文件映射到本地_设置存储数据映射到本地_并开发java应用_连接redis---分布式云原生部署架构搭建011

可以看到java应用的部署过程,首先我们要准备一个java应用,并且我们,用docker,安装一个redis 首先我们去start.spring.io 去生成一个简单的web项目,然后用idea打开 选择以后下载 放在这里,然后我们去安装redis 在公共仓库中找到redis . 可以看到它里面介绍说把数据放到了/dat…

Ansys Zemax|在设计抬头显示器(HUD)时需要使用哪些工具?

附件下载 联系工作人员获取附件 汽车抬头显示器或汽车平视显示器,也被称为HUD,是在汽车中显示数据的透明显示器,不需要用户低头就能看到他们需要的重要资讯。这个名字的由来是由于该技术能够让飞行员在头部“向上”并向前看的情况下查看信息…

第五节:如何使用其他注解方式从IOC中获取bean(自学Spring boot 3.x的第一天)

大家好,我是网创有方,上节我们实践了通过Bean方式声明Bean配置。咱们这节通过Component和ComponentScan方式实现一个同样功能。这节实现的效果是从IOC中加载Bean对象,并且将Bean的属性打印到控制台。 第一步:创建pojo实体类studen…

人工智能AI风口已开:如何赋予UI设计与视频剪辑新生命

随着科技的浪潮不断向前推进,人工智能(AI)正以惊人的速度重塑着我们的世界,特别是在创意产业的核心领域——UI设计与视频剪辑中,AI正逐步成为驱动行业创新与变革的关键力量。在这个AI技术全面开花的新时代,…

搭建企业内网pypi镜像库,让python在内网也能像互联网一样安装pip库

目录 知识点实验1.服务器安装python2.新建一个目录/mirror/pip,用于存储pypi文件,作为仓库目录3.下载python中的所需包放至仓库文件夹/mirror/pip3.1. 新建requirement.py脚本(将清华pypi镜像库文件列表粘贴到requirement.txt文件中&#xff…

Hadoop版本演变、分布式集群搭建

Hadoop版本演变历史 Hadoop发行版非常的多,有华为发行版、Intel发行版、Cloudera Hadoop(CDH)、Hortonworks Hadoop(HDP),这些发行版都是基于Apache Hadoop衍生出来的。 目前Hadoop经历了三个大的版本。 hadoop1.x:HDFSMapReduce hadoop2.x…

mtu 1500 qdisc noop state DOWN group default qlen 1000问题的解决

问题描述 1、打开虚拟机终端,root身份启动ens网卡(一般情况下还是会直接报错 ifup ens33 2、停止网卡设置disable再启动 systemctl stop NetworkManager 不报错即可 systemctl disable NetworkManagerservice network restart出现了绿色的OK啦&#…

流水线作业模拟程序

目录 一 设计原型 二 后台源码 一 设计原型 二 后台源码 namespace 流水线作业模拟 {public partial class Form1 : Form{public Form1(){InitializeComponent();}private int Count 0;private bool IsStop false;private void uiLight1_Click(object sender, EventArgs e…

某麦网自动刷新抢票脚本——手机端(高级版)

某麦网自动刷新抢票脚本——电脑端 小白操作-抵制黄牛–需要更好用更高级关注获取 如何用Python自动抢大麦网演出票? 在数字化时代,购票已经成为我们生活的一部分,无论是音乐会、话剧、体育赛事还是各种展览,抢票几乎成了一项“…

[每周一更]-(第103期):GIT初始化子模块

文章目录 初始化和更新所有子模块分步骤操作1. 克隆包含子模块的仓库2. 初始化子模块3. 更新子模块 查看子模块状态提交子模块的更改处理子模块路径错误的问题 该问题的缘由是因为:在写某些代码的时候,仓库中有些文件夹,只提交了文件夹名称到…

C# SocketUDP服务器,组播

SocketUDP 自己即是服务器又是客户端 ,在发消息只需要改成对方ip和端口号即可 前提对方必须开启服务器 socket.Bind(new IPEndPoint(IPAddress.Parse("192.168.107.72"), 8080)); 控件:Button,TextBox,RichTextBox 打开自己服务器 public…

六、资产安全—信息分级资产管理与隐私保护(CISSP)

目录 1.信息分级 2.信息分级方法 3.责任的层级 4.资产管理 5.隐私数据管理角色 6.数据安全控制 7.数据保护方案 8.使用安全基线 六、资产安全—数据管理(CISSP): 五、身份与访问管理—身份管理和访问控制管理(CISSP): 1.信息分级 信息分级举列: 2.信息分级方…

Halcon 文本文件操作,形态学

一文件的读写 *******************************************************向文本文件写入字符串内容*************************************************************read_image (Image, fabrik)threshold (Image, Region, 0, 120)area_center (Region, Area, Row, Column)open_…

记录一下MATLAB优化器出现的问题和解决

今天MATLAB优化器出了点问题。我想了想,决定解决一下,不然后面项目没有办法进行下去。 我忘了截图了。 具体来说,是出现了下面的问题。 Gurobi: Cplex: 在上次为了强化学习调整了Pytoch环境以后(不知道是不是这个原因&#…

Mac(M1芯片)安装多个jdk,Mac卸载jdk

1.jdk下载 oracle官方链接:oracle官方下载链接 2.安装 直接下一步,下一步就行 3.查看是否安装成功 出现下图内容表示安装成功。 4.配置环境变量 open -e .bash_profile 路径建议复制过去 #刷新环境变量 source ~/.bash_profile 5.切换方法 6.jdk…

页分裂和页合并——Java全栈知识(33)

上篇文章我们讲到了 MySQL 的数据页,我们说到了 InnoDB 的索引是以 B树的形式构建的,而且 B树的节点都是一个数据页。 但是 B树在使用过程中难免会有节点分裂和节点合并的过程。 因为我们是以数据页为基本单位构造的 B树,那么 B树的节点分裂和…

火锅食材配送小程序的作用有什么

火锅店、麻辣烫店、餐厅等对火锅丸子食材的需求量很高,还有普通消费者零售等,市场中或城市里总是有着较为知名的食材店或厂商,通过产品质量、口碑、宣传、老客复购等获得更多生意营收。 线下生意放缓,需要商家拓宽渠道。运用雨科…

7thonline第七在线受邀出席零售业卓越运营联盟(COER)2024

近期,一场汇集行业精英、探讨卓越运营的盛会——零售业卓越运营联盟(COER)2024论坛开幕。此次论坛吸引了全球众多零售业者的关注,7thonline第七在线创始人马克骏先生也应邀参与该论坛,共同探讨零售业的未来发展趋势。 …

【保姆级详细介绍JavaScript初识及基本语法】

🎥博主:程序员不想YY啊 💫CSDN优质创作者,CSDN实力新星,CSDN博客专家 🤗点赞🎈收藏⭐再看💫养成习惯 ✨希望本文对您有所裨益,如有不足之处,欢迎在评论区提出…

Java代码基础算法练习-判断学生成绩等级-2024.06.28

任务描述: 输入一个学生的成绩(成绩大于等于 0 并小于等于 100),根据成绩判断学生成绩的等级。 60 分以下不及格;60-70 分为及格;70-80 分为中等;80-90 分为良好;90 分以上为优秀。 …