Giter VIP home page Giter VIP logo

Comments (6)

lazarusA avatar lazarusA commented on July 24, 2024 1

You should rename it to the previous name, plus the operation applied.

from dimensionaldata.jl.

rafaqz avatar rafaqz commented on July 24, 2024 1

Broadcasting is a huge use case of DimArray and arrays generally in Julia. Its how everything works internally in Rasters.jl - DiskArrays.jl has lazy broadcasting over big data so we leverage this.

We could (should) allow you to specify the name in broadcast_dims which we own - but it doesn't have the nice syntax of base broadcasting.

This is just a hard problem.

We want the best generic native julia syntax, and we want names to propagate intelligently.

from dimensionaldata.jl.

rafaqz avatar rafaqz commented on July 24, 2024

Yeah, there are for and against for this. I think the question isnt about broadcast but if similar keeps the name or not.

Often the name says something about the data that the broadcast totally changes. And raw similar contains no data and is completely uninitialised. So having a name is a bit odd.

But IDK, I also see your point. Im open to changing it. Maybe try a PR changing similar and see what breaks.

from dimensionaldata.jl.

JoshuaBillson avatar JoshuaBillson commented on July 24, 2024

You should rename it to the previous name, plus the operation applied.

The use-case that prompted this issue was converting digital numbers into reflectance for satellite imagery. For example, calculating the surface-reflectance for Sentinel 2 imagery is done as follows:

sentinel .* 0.0001f0

In this case, if a layer has the name :B04, I would like it to retain this after converting it to reflectance. Otherwise, downstream code that depends on the band name will break. The current solution is to rely on rebuild to restore the original name, but this can be quite tedious in practice and is easy to forget about. Layer names could also get long after applying multiple operations in sequence, such as (landsat .* 0.0000275f0) .+ -0.2f0.

from dimensionaldata.jl.

rafaqz avatar rafaqz commented on July 24, 2024

This is the problem, what to do in this case:

mycustomfunction.(sentinel .* 0.0001f0 .* some_other_dim_array.^2) ./ yet_another_dim_array

Its a broadcast just like yours, and at the level of similar we cant tell which is which.

Doing what you want probably requires putting name rules into our broadcast mechanisms. Its possible, but not easy.

(Or we can let precedence win, maybe that will be predictable enough that users can rearrange their functions so the right name "wins" but even so should this still be called :B04 ?)

from dimensionaldata.jl.

JoshuaBillson avatar JoshuaBillson commented on July 24, 2024

I suppose that one could use modify in such cases, which will retain the name of the desired array. You could also extract the data of all arrays whose name you don't want to retain, so that only one operand is a DimArray.

Perhaps we should consider that broadcasting directly over a DimArray is a bad idea? As you pointed out, it can be difficult to determine the identity of the output array based solely on the input. It might be better to provide a method that requires users to specify the name of the output.

from dimensionaldata.jl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.