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

news2024/10/5 16:01:24

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

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

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.coloradmin.cn/o/1874087.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

基于多模态知识图谱的多模态推理-MR-MKG

MR-MKG论文中提出了一种新的多模态推理方法,即利用多模态知识图(Multimodal Knowledge Graph, MMKG)进行多模态推理的方法。这种方法旨在通过从MMKG中学习,扩展大型语言模型(LLMs)的多模态知识。 1 三个模…

【AUTOSAR 基础软件】DEM模块详解(诊断故障管理)

文章包含了AUTOSAR基础软件(BSW)中DEM模块相关的内容详解。本文从ISO标准,AUTOSAR规范解析,ISOLAR-AB配置以及模块相关代码分析四个维度来帮读者清晰的认识和了解DEM这一基础软件模块。文中涉及的ISOLAR-AB配置以及模块相关代码都…

深度相机识别物体——实现数据集准备与数据集分割

一、数据集准备——Labelimg进行标定 1.安装labelimg——pip install labelimg -i https://pypi.tuna.tsinghua.edu.cn/simple 2.建立相应的数据集存放文件夹 3.打开labelimg,直接在命令行输入labelimg即可,并初始化 4.开始标注,设置标注好…

[Cloud Networking] VLAN

1 为什么需要 VLAN(Virtual Local Area Network) VLAN是一个逻辑网络,VLAN将设备/用户进行逻辑分组,VLAN需要在Switch上创建。为什么需要这样呢?为何不能所有设备都在同一个网络? 如下网络,如果设备过多,…

五线谱与简谱有什么区别 五线谱简谱混排怎么打 吉他谱软件哪个好

五线谱与简谱作为音乐记谱领域的两大主流系统,各自承载着深厚的历史渊源与独特的表现力,并在全球范围内被不同程度地接受和应用。尽管两者都是为了记录音乐作品中的音高和节奏信息,但其内在机制、适用范围以及学习曲线存在显著差别。下面我们…

QT拖放事件之七:子类化QMimeData,实现对多个自定义类型进行数据

1、前提说明 /*自定义的MIME类型数据存储在QMimeData对象中, 存在两种方法:1. setData(...)可以把自定义类型的数据以QByteArray的形式直接存储在QMimeData中,但是使用此方法一次只能对一个MIME类型进行处理(可参考 QT拖放事件六:自定义MIME类型的存储及读取demo ) 一文。…

动手学深度学习(Pytorch版)代码实践 -计算机视觉-44目标检测算法综述:R-CNN、SSD和YOLO

41~44目标检测算法综述:R-CNN、SSD和YOLO 1. 区域卷积神经网络 (R-CNN 系列) 1.1 R-CNN 使用启发式搜索算法来选择锚框。使用预训练模型对每个锚框提取特征(每个锚框视为一张图片,使用 CNN 提取特征)。训练 SVM 进行类别分类&a…

Halcon 文本文件操作,形态学

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

Linux启动elasticsearch,提示权限不够

Linux启动elasticsearch,提示权限不够,如下图所示: 解决办法: 设置文件所有者,即使用户由权限访问文件 sudo chown -R 用户名[:新组] ./elasticsearch-8.10.4 //切换到elasticsearch-8.10.4目录同级 chown详细格式…

面对.rmallox勒索病毒:如何有效防范及应对

引言: 在当今数字化社会,网络安全问题日益严重,勒索病毒成为企业和个人不可忽视的威胁之一。最近出现的.rmallox勒索病毒更是给全球各地的用户带来了严重的数据安全问题。本文将探讨.rmallox勒索病毒的特点、感染方式及应对策略,…

format()方法——格式化字符串

自学python如何成为大佬(目录):https://blog.csdn.net/weixin_67859959/article/details/139049996?spm1001.2014.3001.5501 语法介绍 format()可以对数据进行格式化处理操作,语法如下: format(value, format_spec) format_spec为格式化解释。当参数…

【代码工厂】简单地图生成

要求 (图片来自codingame) 代码 # 定义一个函数,用于生成模式 def generate_pattern(n, a, border_char): # 初始化一个空列表,用于存储生成地图pattern []# 最上面那一行的处理line n * border_charpattern.append(line)# 遍…

Zabbix如何帮助企业将监控数据转化为竞争优势

By Fernanda Moraes 在我们生活的高度互联世界中,变化以越来越快和激烈的速度发生。这影响了消费者的认知与行为,迫使零售商寻找更有效的方式来吸引客户。Linx 是 StoneCo 集团旗下的一家公司,也是零售技术专家,Linx了解这一点&am…

两张图片怎样拼在一起?将两张图片拼在一起的几种方法介绍

两张图片怎样拼在一起?拼接两张图片是一种常见的编辑技巧,能够将不同的视觉元素融合成一个整体,从而创造出更加生动和丰富的图像效果。无论是为了设计创意作品、制作社交媒体内容,还是简单地为个人相册增添趣味,掌握如…

一个人 三个月 干了二十万

相信很多人是被这个标题吸引进来的,但我并不是标题党,我也很讨厌标题党,这篇文章也不在乎流量,更多的是想记录下。 出来创业三个多月了,给大家汇报一下这段时间的业绩吧。一个人,三个多月,干了…

PlatformIO开发环境

PlatformIO是一个开源的生态系统,用于构建物联网应用,它支持多种微控制器(MCU)和硬件开发板,并且与各种IDE集成良好,如VSCode, Atom等,使得跨平台的固件开发变得更加简单和高效。 ### 平台介绍…

安卓速度下载v1.0.5/聚合短视频解析下载

功能特色 短视频下载与高级管理 – 支持短视频下载,为您提供一系列高级视频管理功能包括视频内容提取、智能防重复技术、视频体积压缩以及视频转换成GIF图片等; 磁-力链接下载升级 – 现支持磁力链接下载,实现边下载边播放的便捷体验&#x…

typescript学习回顾(四)

今天来分享下ts中的类,关于ts中的类的概念,面向对象的一种思想,以及类里面的一些属性成员,一些基础的用法,后面会有一个小练习。 类 基本概念 我的理解:类是编程语言中面向对象的一种思想,一…

flutter是app跨平台最优解吗?

哈喽,我是老刘 最近在知乎上看到这样一个问题 我们先来解释一下问题中碰到的几个现象的可能原因,然后聊聊跨平台的最优解问题 问题解释 1、跟手、丝滑问题 这个问题其实很多人是有误解的,觉得原生的就丝滑跟手 其实不是这样的 我在做Flut…

【内网安全】组策略同步-不出网隧道上线-TCP转ICMP

目录 域控-防火墙-组策略对象同步演示1、打开组策略管理,新建一个GPO连接 取名fhq(防火墙)2、编辑fhq并设置防火墙状态3、命令:gpupdate/force 更新策略4、域控主机新增规则5、域内用户主机更新规则 域控-防火墙-组策略不出网上线演示 ICMP协议上线&…