Giter Club home page Giter Club logo

nmrpoise's People

Contributors

yongrenjie avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

nmrpoise's Issues

Use lists for NM and MDS methods – remove py3 dependency

I have a nagging feeling that we don't actually need numpy & everything can be done purely using lists...
This would mean that we don't actually need to use Py3 at all... and everything can be built into TS directly. It seems ambitious, but I don't see why not.

Memoisation

This could probably be built into a decorator (the same one which counts number of experiments ran). Not sure if this is a good idea because the cost function has noise - so if we get a poor value the first time we acquire it, this will always persist - in the worst case scenario we could end up stuck in a loop. Maybe code it to re-acquire the spectrum after a certain number of times?

Check for folder existence before pickling/dilling

If the installation is done manually, there's a chance that the pypopt/routines and pypopt/cost_functions folders are not there; the Python scripts should check for their existence and make them first if necessary.

Trying to open a file object f = open("/path/to/nonexistent_dir/file", "wb") directly will throw an IOError.

Linting

For pypopt-be.py and pypopt-makecf.py, to be precise.

Separate AU programme like cost functions...

The user shouldn't have to edit the source code depending on the intended usage...!

It's not obvious what the best way to do this is. We could make a new folder inside poise_backend, along with routines and cost_functions (big downside: TopSpin cannot detect this folder automatically). Or we could install the AU programmes into the TopSpin directory. The name of the AU programme would need to be tied to the Routine. I'm already running into issues where I forget to change the AU programme between experiments...!

Error checking in install.sh

Some error checking is needed for the file management commands (cp, mkdir, ...) for example, most people shouldn't have issues with permissions, but what happens if (e.g.) $TOPSPINDIR is not set correctly and then the installer tries to copy the Python scripts to a non-existent directory. We need to capture the error code

Auto-detect whether WaveMaker shapes are needed?

For experiments that utilise WaveMaker shapes, they need to be generated with XCMD("wvm -q") before every acquisition. However, if we run this on a pulse programme that doesn't need WaveMaker shapes, it will throw an error before every acquisition, which has to be manually closed by the user:

Screenshot 2020-06-03 at 1 41 12 AM

So we need a way of running that line IF... otherwise don't...

Install to ALL TopSpin directories

Instead of giving the user an error whenever multiple TopSpin directories are present, why not just.... install to.... ALL of them?????

download

Provide entry point for TS installation

Installing from wheels (which pip prefers) doesn't actually install into TopSpin. However, installing from sdist, viz. pip install nmrpoise --no-binary :all: works just fine. I think I should just not upload wheels to PyPI.

But I am also thinking, maybe even if it doesn't install into TopSpin, we should provide a setuptools entry point that runs topspin_install.py.

Extra checks if cost_function() is defined with a different name

When defining a cost function, the function has to be defined with the name cost_function(), because of this line:

https://github.com/yongrenjie/poptpy/blob/ac4943380537ffcda899db6796e4bec695ee9ecb/poptpy/poptpy_be.py#L52

It's probably a good idea to keep the function naming consistent, but we can catch accidental typos by checking if ld only has one key and if so, using that function as the cost function, viz.

ld = {}
exec(open("b.py").read(), globals(), ld)

try:
    cost_function = ld["cost_function"]
except KeyError as e:
    if len(ld) == 1:
        cost_function = ld[list(ld)[0]]
    else:
        raise e

print(cost_function())

Implement Py-BOBYQA optimiser

The tolerances are the tricky part here -- since rho_end has to be one value, we need to scale every parameter such that the tolerance is the same.

That entails adding some flexibility into many of the other functions such that lb and ub aren't hardcoded to be 0 and 1 for everything.

Create some sample cost functions

Ideas:

  • total intensity (sqrt(real^2+imag^2), or just the real) - can use for HSQC
  • 1D NOE (using spoffs2)
  • Similarity function (how to specify expno/procno? we don't have this capability yet)
  • var(atan(re/absim)) (this is still lacking justification)
  • selective pulse (for selective excitation eg S/DPFGSE)
  • selective pulse (for Zangger-Sterk)
  • other pulse shapes, to demonstrate WaveMaker use

Catch pybobyqa errors

For example, this:

****** Py-BOBYQA Results ******
Exit flag = -1
Error (bad input): gap between lower and upper must be at least 2*rhobeg


Add counter for number of spectra measured (<= nfev)

nfev overestimates the time taken because it includes function evaluations outside the ranges, which don't actually lead to spectra being acquired.

The most direct solution is to use a global variable, but there should be something better...

NullPointerError pops up if the AU programme runs a Python script

This doesn't actually stop the optimisation from finishing (as evidenced by the logs). However, it stops the optima from being stored in the dataset (bad), and also prevents the popup at the end notifying the user (doesn't matter quite so much).

From the stack trace it appears to be related to the errlog context manager which surrounds the main loop. There appears to be a problem with closing the ferr file. But honestly, the stack trace is incredibly useless, so I don't actually know what's causing it.

Kill backend subprocess if frontend is terminated

If the frontend is terminated (e.g. using TopSpin's kill command) while the backend is still running, the backend subprocess isn't terminated properly.

'Which one?' 'I dunno, it's your house. Just check each object.' 'Check it for what?' 'Whether it looks like it might have touched a paper towel at some point and then forgotten to let go.' '...' 'You can also Google to learn how to check which things are using which resources.' 'You know, I'll just leave the towel there and try again tomorrow.'

(1888: Still in Use)

Especially on Windows, this can cause issues with trying to open / delete / otherwise modify the poptpy.log file. This includes seemingly innocuous things such as renaming the EXPNO in TopSpin (which tries to rename the entire EXPNO folder).

This can be fixed with e.g. Stop-Process -name python from PowerShell, but there has to be a better way. I don't know how TopSpin implements the kill function, but we need some cleanup code to terminate the subprocess (perhaps a subprocess context manager - not sure if that exists in Py2.7).

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.